/** @file stack.c
 * Stack lib.
 *
 * Debug
 *  DEBUG - normal debug mode, prints executed opcodes.
 *  DEBUG_JSTACK - after each opcode prints the jstack.
 *
 * Copyright (C) 2007
 *   Renan Mendes Carvalho <aitherios@gmail.com>
 *   Pedro Marinho <pedro7x@gmail.com>
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

#include "stack.h"
#include "stack_int.h"

/**
 * Check if previous instruction is wide (opcode 0xc4)
 */
#define ISWIDE (0xc4 == *((u1 *)getpc() - 2))

/**
 * Execute a method.
 * Local variable area is define by a passed pointer. In fact, the operand stack
 * from the caller method, if existent, is the current local variables area.
 * @param it the instance.
 * @param function_num method number to be used.
 * @param local_variables_init the start point for the local variables area.
 */
void
execute_method (instance *it, int function_num, void * local_variables_init)
{
  method_info * mi;
  void * operand_stack;
  int diff; /**< diference between stack poniter and local variables init pointer*/
  u2 param_num; /**< number of method variables*/
  u4 code_length;
  u4 opcode;
  u1 * pc;
  int i;

  mi = it->cf->methods + function_num;
  pc = mi->attributes->info;
  setpc ((void *)pc);
  memcpy (&param_num,  pc + 2, 2);
  meminv (&param_num, 2);
  memcpy (&code_length, pc + 4, 4);
  meminv (&code_length, 4);

  /* solve if local variables area is bigger than previous operand stack passed
   * by previous caller method
   */
  diff = (int)((int*)getsp_java() - (int*)local_variables_init);
  if(0 < param_num * 4 - diff)
    push_java(param_num * 4 - diff);
  /*operand stack*/
  operand_stack = getsp_java();

# ifdef DEBUG
  printf(">>executing method %#.4x..\n", function_num);
  printf(">>pc: %p param_num: %#.4x code_length: %#.4x\n", getpc(),  param_num, code_length);
  fflush(NULL);
# endif
# ifdef DEBUG_JSTACK
  print_java_stack();
  fflush(NULL);
# endif
  /* opcodes reading */
  for ( i = 8, setpc((void *)(pc + i)); i < code_length + 8; i++, setpc((void *)(pc + i)) )
    {

#     ifdef DEBUG
      printf(">>pc: %p opcode: %#4.2x (%s ", getpc(), *((u1 *)getpc()), opcode_string( *((u1 *)getpc())) );
      fflush(NULL);
#     endif

      opcode = *((u1 *)getpc());
      /*sets pc after the opcode*/
      incpc(1); 
      switch ( opcode )
	{
	  /* after each instruction, i is increased so the relative byte count
	   * for the scanning is updated. Essencial for keeping the pc at the
	   * correct position.
	   */
	case 0x00: 
    i += op_nop (it,local_variables_init,operand_stack);
	  break; 
	case 0x01: 
    i += op_aconst_null (it,local_variables_init,operand_stack);
	  break; 
	case 0x02: 
    i += op_iconst_m1 (it,local_variables_init,operand_stack);
	  break; 
	case 0x03: 
    i += op_iconst_0 (it,local_variables_init,operand_stack);
	  break; 
	case 0x04: 
    i += op_iconst_1 (it,local_variables_init,operand_stack);
	  break; 
	case 0x05: 
    i += op_iconst_2 (it,local_variables_init,operand_stack);
	  break; 
	case 0x06: 
    i += op_iconst_3 (it,local_variables_init,operand_stack);
	  break; 
	case 0x07: 
    i += op_iconst_4 (it,local_variables_init,operand_stack);
	  break; 
	case 0x08: 
    i += op_iconst_5 (it,local_variables_init,operand_stack);
	  break; 
	case 0x09: 
    i += op_lconst_0 (it,local_variables_init,operand_stack);
	  break; 
	case 0x0a: 
    i += op_lconst_1 (it,local_variables_init,operand_stack);
	  break; 
	case 0x0b: 
    i += op_fconst_0 (it,local_variables_init,operand_stack);
	  break; 
	case 0x0c: 
    i += op_fconst_1 (it,local_variables_init,operand_stack);
	  break; 
	case 0x0d: 
    i += op_fconst_2 (it,local_variables_init,operand_stack);
	  break; 
	case 0x0e: 
    i += op_dconst_0 (it,local_variables_init,operand_stack);
	  break; 
	case 0x0f: 
    i += op_dconst_1 (it,local_variables_init,operand_stack);
	  break; 
	case 0x10: 
    i += op_bipush (it,local_variables_init,operand_stack);
	  break; 
	case 0x11: 
    i += op_sipush (it,local_variables_init,operand_stack);
	  break; 
	case 0x12: 
    i += op_ldc (it,local_variables_init,operand_stack);
	  break; 
	case 0x13: 
    i += op_ldc_w (it,local_variables_init,operand_stack);
	  break; 
	case 0x14: 
    i += op_ldc2_w (it,local_variables_init,operand_stack);
	  break; 
	case 0x15: 
    i += op_iload (it,local_variables_init,operand_stack);
	  break; 
	case 0x16: 
	  i += op_lload (it,local_variables_init,operand_stack);
	  break; 
	case 0x17: 
	  i += op_fload (it,local_variables_init,operand_stack);
	  break; 
	case 0x18: 
	  i += op_dload (it,local_variables_init,operand_stack);
	  break; 
	case 0x19: 
	  i += op_aload (it,local_variables_init,operand_stack);
	  break; 
	case 0x1a: 
	  i += op_iload_0 (it,local_variables_init,operand_stack);
	  break; 
	case 0x1b: 
	  i += op_iload_1 (it,local_variables_init,operand_stack);
	  break; 
	case 0x1c: 
	  i += op_iload_2 (it,local_variables_init,operand_stack);
	  break; 
	case 0x1d: 
	  i += op_iload_3 (it,local_variables_init,operand_stack);
	  break; 
	case 0x1e: 
	  i += op_lload_0 (it,local_variables_init,operand_stack);
	  break; 
	case 0x1f: 
	  i += op_lload_1 (it,local_variables_init,operand_stack);
	  break; 
	case 0x20: 
	  i += op_lload_2 (it,local_variables_init,operand_stack);
	  break; 
	case 0x21: 
	  i += op_lload_3 (it,local_variables_init,operand_stack);
	  break; 
	case 0x22: 
	  i += op_fload_0 (it,local_variables_init,operand_stack);
	  break; 
	case 0x23: 
	  i += op_fload_1 (it,local_variables_init,operand_stack);
	  break; 
	case 0x24: 
	  i += op_fload_2 (it,local_variables_init,operand_stack);
	  break; 
	case 0x25: 
	  i += op_fload_3 (it,local_variables_init,operand_stack);
	  break; 
	case 0x26: 
	  i += op_dload_0 (it,local_variables_init,operand_stack);
	  break; 
	case 0x27: 
	  i += op_dload_1 (it,local_variables_init,operand_stack);
	  break; 
	case 0x28: 
	  i += op_dload_2 (it,local_variables_init,operand_stack);
	  break; 
	case 0x29: 
	  i += op_dload_3 (it,local_variables_init,operand_stack);
	  break; 
	case 0x2a: 
	  i += op_aload_0 (it,local_variables_init,operand_stack);
	  break; 
	case 0x2b: 
	  i += op_aload_1 (it,local_variables_init,operand_stack);
	  break; 
	case 0x2c: 
	  i += op_aload_2 (it,local_variables_init,operand_stack);
	  break; 
	case 0x2d: 
	  i += op_aload_3 (it,local_variables_init,operand_stack);
	  break; 
	case 0x2e: 
	  i += op_iaload (it,local_variables_init,operand_stack);
	  break; 
	case 0x2f: 
	  i += op_laload (it,local_variables_init,operand_stack);
	  break; 
	case 0x30: 
	  i += op_faload (it,local_variables_init,operand_stack);
	  break; 
	case 0x31: 
	  i += op_daload (it,local_variables_init,operand_stack);
	  break; 
	case 0x32: 
	  i += op_aaload (it,local_variables_init,operand_stack);
	  break; 
	case 0x33: 
	  i += op_baload (it,local_variables_init,operand_stack);
	  break; 
	case 0x34: 
	  i += op_caload (it,local_variables_init,operand_stack);
	  break; 
	case 0x35: 
	  i += op_saload (it,local_variables_init,operand_stack);
	  break; 
	case 0x36: 
	  i += op_istore (it,local_variables_init,operand_stack);
	  break; 
	case 0x37: 
	  i += op_lstore (it,local_variables_init,operand_stack);
	  break; 
	case 0x38: 
	  i += op_fstore (it,local_variables_init,operand_stack);
	  break; 
	case 0x39: 
	  i += op_dstore (it,local_variables_init,operand_stack);
	  break; 
	case 0x3a: 
	  i += op_astore (it,local_variables_init,operand_stack);
	  break; 
	case 0x3b: 
	  i += op_istore_0 (it,local_variables_init,operand_stack);
	  break; 
	case 0x3c: 
	  i += op_istore_1 (it,local_variables_init,operand_stack);
	  break; 
	case 0x3d: 
	  i += op_istore_2 (it,local_variables_init,operand_stack);
	  break; 
	case 0x3e: 
	  i += op_istore_3 (it,local_variables_init,operand_stack);
	  break; 
	case 0x3f: 
	  i += op_lstore_0 (it,local_variables_init,operand_stack);
	  break; 
	case 0x40: 
	  i += op_lstore_1 (it,local_variables_init,operand_stack);
	  break; 
	case 0x41: 
	  i += op_lstore_2 (it,local_variables_init,operand_stack);
	  break; 
	case 0x42: 
	  i += op_lstore_3 (it,local_variables_init,operand_stack);
	  break; 
	case 0x43: 
	  i += op_fstore_0 (it,local_variables_init,operand_stack);
	  break; 
	case 0x44: 
	  i += op_fstore_1 (it,local_variables_init,operand_stack);
	  break; 
	case 0x45: 
	  i += op_fstore_2 (it,local_variables_init,operand_stack);
	  break; 
	case 0x46: 
	  i += op_fstore_3 (it,local_variables_init,operand_stack);
	  break; 
	case 0x47: 
	  i += op_dstore_0 (it,local_variables_init,operand_stack);
	  break; 
	case 0x48: 
	  i += op_dstore_1 (it,local_variables_init,operand_stack);
	  break; 
	case 0x49: 
	  i += op_dstore_2 (it,local_variables_init,operand_stack);
	  break; 
	case 0x4a: 
	  i += op_dstore_3 (it,local_variables_init,operand_stack);
	  break; 
	case 0x4b: 
	  i += op_astore_0 (it,local_variables_init,operand_stack);
	  break; 
	case 0x4c: 
	  i += op_astore_1 (it,local_variables_init,operand_stack);
	  break; 
	case 0x4d: 
	  i += op_astore_2 (it,local_variables_init,operand_stack);
	  break; 
	case 0x4e: 
	  i += op_astore_3 (it,local_variables_init,operand_stack);
	  break; 
	case 0x4f: 
	  i += op_iastore (it,local_variables_init,operand_stack);
	  break; 
	case 0x50: 
	  i += op_lastore (it,local_variables_init,operand_stack);
	  break; 
	case 0x51: 
	  i += op_fastore (it,local_variables_init,operand_stack);
	  break; 
	case 0x52: 
	  i += op_dastore (it,local_variables_init,operand_stack);
	  break; 
	case 0x53: 
	  i += op_aastore (it,local_variables_init,operand_stack);
	  break; 
	case 0x54: 
	  i += op_bastore (it,local_variables_init,operand_stack);
	  break; 
	case 0x55: 
	  i += op_castore (it,local_variables_init,operand_stack);
	  break; 
	case 0x56: 
	  i += op_sastore (it,local_variables_init,operand_stack);
	  break; 
	case 0x57: 
	  i += op_pop (it,local_variables_init,operand_stack);
	  break; 
	case 0x58: 
	  i += op_pop2 (it,local_variables_init,operand_stack);
	  break; 
	case 0x59: 
	  i += op_dup (it,local_variables_init,operand_stack);
	  break; 
	case 0x5a: 
	  i += op_dup_x1 (it,local_variables_init,operand_stack);
	  break; 
	case 0x5b: 
	  i += op_dup_x2 (it,local_variables_init,operand_stack);
	  break; 
	case 0x5c: 
	  i += op_dup2 (it,local_variables_init,operand_stack);
	  break; 
	case 0x5d: 
	  i += op_dup2_x1 (it,local_variables_init,operand_stack);
	  break; 
	case 0x5e: 
	  i += op_dup2_x2 (it,local_variables_init,operand_stack);
	  break; 
	case 0x5f: 
	  i += op_swap (it,local_variables_init,operand_stack);
	  break; 
	case 0x60: 
	  i += op_iadd (it,local_variables_init,operand_stack);
	  break; 
	case 0x61: 
	  i += op_ladd (it,local_variables_init,operand_stack);
	  break; 
	case 0x62: 
	  i += op_fadd (it,local_variables_init,operand_stack);
	  break; 
	case 0x63: 
	  i += op_dadd (it,local_variables_init,operand_stack);
	  break; 
	case 0x64: 
	  i += op_isub (it,local_variables_init,operand_stack);
	  break; 
	case 0x65: 
	  i += op_lsub (it,local_variables_init,operand_stack);
	  break; 
	case 0x66: 
	  i += op_fsub (it,local_variables_init,operand_stack);
	  break; 
	case 0x67: 
	  i += op_dsub (it,local_variables_init,operand_stack);
	  break; 
	case 0x68: 
	  i += op_imul (it,local_variables_init,operand_stack);
	  break; 
	case 0x69: 
	  i += op_lmul (it,local_variables_init,operand_stack);
	  break; 
	case 0x6a: 
	  i += op_fmul (it,local_variables_init,operand_stack);
	  break; 
	case 0x6b: 
	  i += op_dmul (it,local_variables_init,operand_stack);
	  break; 
	case 0x6c: 
	  i += op_idiv (it,local_variables_init,operand_stack);
	  break; 
	case 0x6d: 
	  i += op_ldiv (it,local_variables_init,operand_stack);
	  break; 
	case 0x6e: 
	  i += op_fdiv (it,local_variables_init,operand_stack);
	  break; 
	case 0x6f: 
	  i += op_ddiv (it,local_variables_init,operand_stack);
	  break; 
	case 0x70: 
	  i += op_irem (it,local_variables_init,operand_stack);
	  break; 
	case 0x71: 
	  i += op_lrem (it,local_variables_init,operand_stack);
	  break; 
	case 0x72: 
	  i += op_frem (it,local_variables_init,operand_stack);
	  break; 
	case 0x73: 
	  i += op_drem (it,local_variables_init,operand_stack);
	  break; 
	case 0x74: 
	  i += op_ineg (it,local_variables_init,operand_stack);
	  break;
	case 0x75: 
	  i += op_lneg (it,local_variables_init,operand_stack);
	  break; 
	case 0x76: 
	  i += op_fneg (it,local_variables_init,operand_stack);
	  break; 
	case 0x77: 
	  i += op_dneg (it,local_variables_init,operand_stack);
	  break; 
	case 0x78: 
	  i += op_ishl (it,local_variables_init,operand_stack);
	  break; 
	case 0x79: 
	  i += op_lshl (it,local_variables_init,operand_stack);
	  break; 
	case 0x7a: 
	  i += op_ishr (it,local_variables_init,operand_stack);
	  break; 
	case 0x7b: 
	  i += op_lshr (it,local_variables_init,operand_stack);
	  break; 
	case 0x7c: 
	  i += op_iushr (it,local_variables_init,operand_stack);
	  break; 
	case 0x7d: 
	  i += op_lushr (it,local_variables_init,operand_stack);
	  break; 
	case 0x7e: 
	  i += op_iand (it,local_variables_init,operand_stack);
	  break; 
	case 0x7f: 
	  i += op_land (it,local_variables_init,operand_stack);
	  break; 
	case 0x80: 
	  i += op_ior (it,local_variables_init,operand_stack);
	  break; 
	case 0x81: 
	  i += op_lor (it,local_variables_init,operand_stack);
	  break; 
	case 0x82: 
	  i += op_ixor (it,local_variables_init,operand_stack);
	  break; 
	case 0x83: 
	  i += op_lxor (it,local_variables_init,operand_stack);
	  break; 
	case 0x84: 
	  i += op_iinc (it,local_variables_init,operand_stack);
	  break; 
	case 0x85: 
	  i += op_i2l (it,local_variables_init,operand_stack);
	  break; 
	case 0x86: 
	  i += op_i2f (it,local_variables_init,operand_stack);
	  break; 
	case 0x87: 
	  i += op_i2d (it,local_variables_init,operand_stack);
	  break; 
	case 0x88: 
	  i += op_l2i (it,local_variables_init,operand_stack);
	  break; 
	case 0x89: 
	  i += op_l2f (it,local_variables_init,operand_stack);
	  break; 
	case 0x8a: 
	  i += op_l2d (it,local_variables_init,operand_stack);
	  break; 
	case 0x8b: 
	  i += op_f2i (it,local_variables_init,operand_stack);
	  break; 
	case 0x8c: 
	  i += op_f2l (it,local_variables_init,operand_stack);
	  break; 
	case 0x8d: 
	  i += op_f2d (it,local_variables_init,operand_stack);
	  break; 
	case 0x8e: 
	  i += op_d2i (it,local_variables_init,operand_stack);
	  break; 
	case 0x8f: 
	  i += op_d2l (it,local_variables_init,operand_stack);
	  break; 
	case 0x90: 
	  i += op_d2f (it,local_variables_init,operand_stack);
	  break; 
	case 0x91: 
	  i += op_i2b (it,local_variables_init,operand_stack);
	  break; 
	case 0x92: 
	  i += op_i2c (it,local_variables_init,operand_stack);
	  break; 
	case 0x93: 
	  i += op_i2s (it,local_variables_init,operand_stack);
	  break; 
	case 0x94: 
	  i += op_lcmp (it,local_variables_init,operand_stack);
	  break; 
	case 0x95: 
	  i += op_fcmpl (it,local_variables_init,operand_stack);
	  break; 
	case 0x96: 
	  i += op_fcmpg (it,local_variables_init,operand_stack);
	  break; 
	case 0x97: 
	  i += op_dcmpl (it,local_variables_init,operand_stack);
	  break; 
	case 0x98: 
	  i += op_dcmpg (it,local_variables_init,operand_stack);
	  break; 
	case 0x99: 
	  i += op_ifeq (it,local_variables_init,operand_stack);
	  break; 
	case 0x9a: 
	  i += op_ifne (it,local_variables_init,operand_stack);
	  break; 
	case 0x9b: 
	  i += op_iflt (it,local_variables_init,operand_stack);
	  break; 
	case 0x9c: 
	  i += op_ifge (it,local_variables_init,operand_stack);
	  break; 
	case 0x9d: 
	  i += op_ifgt (it,local_variables_init,operand_stack);
	  break; 
	case 0x9e: 
	  i += op_ifle (it,local_variables_init,operand_stack);
	  break; 
	case 0x9f: 
	  i += op_if_icmpeq (it,local_variables_init,operand_stack);
	  break; 
	case 0xa0: 
	  i += op_if_icmpne (it,local_variables_init,operand_stack);
	  break; 
	case 0xa1: 
	  i += op_if_icmplt (it,local_variables_init,operand_stack);
	  break; 
	case 0xa2: 
	  i += op_if_icmpge (it,local_variables_init,operand_stack);
	  break; 
	case 0xa3: 
	  i += op_if_icmpgt (it,local_variables_init,operand_stack);
	  break; 
	case 0xa4: 
	  i += op_if_icmple (it,local_variables_init,operand_stack);
	  break; 
	case 0xa5: 
	  i += op_if_acmpeq (it,local_variables_init,operand_stack);
	  break; 
	case 0xa6: 
	  i += op_if_acmpne (it,local_variables_init,operand_stack);
	  break; 
	case 0xa7: 
	  i += op_goto (it,local_variables_init,operand_stack);
	  break;  
	case 0xa8: 
	  i += op_jsr (it,local_variables_init,operand_stack);
	  break; 
	case 0xa9: 
	  i += op_ret (it,local_variables_init,operand_stack);
	  break; 
	case 0xaa: 
	  i += op_tableswitch (it,local_variables_init,operand_stack);
	  break; 
	case 0xab: 
	  i += op_lookupswitch (it,local_variables_init,operand_stack);
	  break; 
	case 0xac: 
	  i += op_ireturn (it,local_variables_init,operand_stack);
	  break; 
	case 0xad: 
	  i += op_lreturn (it,local_variables_init,operand_stack);
	  break; 
	case 0xae: 
	  i += op_freturn (it,local_variables_init,operand_stack);
	  break; 
	case 0xaf: 
	  i += op_dreturn (it,local_variables_init,operand_stack);
	  break; 
	case 0xb0: 
	  i += op_areturn (it,local_variables_init,operand_stack);
	  break; 
	case 0xb1: 
	  i += op_return (it,local_variables_init,operand_stack);
	  break; 
	case 0xb2: 
	  i += op_getstatic (it,local_variables_init,operand_stack);
	  break; 
	case 0xb3: 
	  i += op_putstatic (it,local_variables_init,operand_stack);
	  break; 
	case 0xb4: 
	  i += op_getfield (it,local_variables_init,operand_stack);
	  break; 
	case 0xb5: 
	  i += op_putfield (it,local_variables_init,operand_stack);
	  break; 
	case 0xb6: 
	  i += op_invokevirtual (it,local_variables_init,operand_stack);
	  break; 
	case 0xb7: 
	  i += op_invokespecial (it,local_variables_init,operand_stack);
	  break; 
	case 0xb8: 
	  i += op_invokestatic (it,local_variables_init,operand_stack);
	  break; 
	case 0xb9: 
	  i += op_invokeinterface (it,local_variables_init,operand_stack);
	  break; 
	case 0xba: 
	  i += op_xxxunusedxxx1 (it,local_variables_init,operand_stack);
	  break; 
	case 0xbb: 
	  i += op_new (it,local_variables_init,operand_stack);
	  break; 
	case 0xbc: 
	  i += op_newarray (it,local_variables_init,operand_stack);
	  break; 
	case 0xbd: 
	  i += op_anewarray (it,local_variables_init,operand_stack);
	  break; 
	case 0xbe: 
	  i += op_arraylength (it,local_variables_init,operand_stack);
	  break; 
	case 0xbf: 
	  i += op_athrow (it,local_variables_init,operand_stack);
	  break; 
	case 0xc0: 
	  i += op_checkcast (it,local_variables_init,operand_stack);
	  break; 
	case 0xc1: 
	  i += op_instanceof (it,local_variables_init,operand_stack);
	  break; 
	case 0xc2: 
	  i += op_monitorenter (it,local_variables_init,operand_stack);
	  break; 
	case 0xc3: 
	  i += op_monitorexit (it,local_variables_init,operand_stack);
	  break; 
	case 0xc4: 
	  i += op_wide (it,local_variables_init,operand_stack);
	  break; 
	case 0xc5: 
	  i += op_multianewarray (it,local_variables_init,operand_stack);
	  break; 
	case 0xc6: 
	  i += op_ifnull (it,local_variables_init,operand_stack);
	  break; 
	case 0xc7: 
	  i += op_ifnonnull (it,local_variables_init,operand_stack);
	  break; 
	case 0xc8: 
	  i += op_goto_w (it,local_variables_init,operand_stack);
	  break; 
	case 0xc9: 
	  i += op_jsr_w (it,local_variables_init,operand_stack);
	  break; 
	case 0xca: 
	  i += op_breakpoint (it,local_variables_init,operand_stack);
	  break; 
	case 0xfe: 
	  i += op_impdep1 (it,local_variables_init,operand_stack);
	  break; 
	case 0xff: 
	  i += op_impdep2 (it,local_variables_init,operand_stack);
	  break; 
	default:
	  errormsg ("execute method", "invalid opcode: ", 0);
	}
#     ifdef DEBUG
      puts("");
      fflush(NULL);
#     endif
#     ifdef DEBUG_JSTACK
      print_java_stack();
      fflush(NULL);
#     endif
    }
# ifdef DEBUG
  puts(">>ending method execution..");
  fflush(NULL);
# endif
}

/**
 * Not and operand. Does nothing.
 * @param it caller method instance
 * @param local_variables_init local variable stack init
 * @param operand_stack operand stack init
 * @return number of bytes consumed by opcode, used to increase pc.
 */
int
op_nop (instance * it, void * local_variables_init, void * operand_stack)
  {
#   ifdef DEBUG
    printf("none)");
    fflush(NULL);
#   endif
    
    return 0;
  }

/**
 * Pushes Null object reference to the stack
 * @param it caller method instance
 * @param local_variables_init local variable stack init
 * @param operand_stack operand stack init
 * @return number of bytes consumed by opcode, used to increase pc.
 */
int
op_aconst_null (instance * it, void * local_variables_init, void * operand_stack)
  {
    u4 *constant;
#   ifdef DEBUG
    printf("none)");
    fflush(NULL);
#   endif
    
    constant=(u4 *)push_java(sizeof(u4));
    *constant=(unsigned int )0;
    
    return 0;
  }

/**
 * Pushes -1 to the stack.
 * @param it caller method instance
 * @param local_variables_init local variable stack init
 * @param operand_stack operand stack init
 * @return number of bytes consumed by opcode, used to increase pc.
 */
int
op_iconst_m1 (instance * it, void * local_variables_init, void * operand_stack)
  {
    s4 *constant;
#   ifdef DEBUG
    printf("none)");
    fflush(NULL);
#   endif
    
    constant=(s4 *)push_java(sizeof(s4));
    *constant=-1;
    
    return 0;
  }

/**
 * Pushes 0 to the stack.
 * @param it caller method instance
 * @param local_variables_init local variable stack init
 * @param operand_stack operand stack init
 * @return number of bytes consumed by opcode, used to increase pc.
 */
int
op_iconst_0 (instance * it, void * local_variables_init, void * operand_stack)
  {
    s4 *constant;
#   ifdef DEBUG
    printf("none)");
    fflush(NULL);
#   endif
    
    constant=(s4 *)push_java(sizeof(s4));
    *constant=0;
    
    return 0;
  }

/**
 * Pushes 1 to the stack.
 * @param it caller method instance
 * @param local_variables_init local variable stack init
 * @param operand_stack operand stack init
 * @return number of bytes consumed by opcode, used to increase pc.
 */
int
op_iconst_1 (instance * it, void * local_variables_init, void * operand_stack)
  {
    s4 *constant;
#   ifdef DEBUG
    printf("none)");
    fflush(NULL);
#   endif
    
    constant=(s4 *)push_java(sizeof(s4));
    *constant=1;
    
    return 0;
  }

/**
 * Pushes 2 to the stack.
 * @param it caller method instance
 * @param local_variables_init local variable stack init
 * @param operand_stack operand stack init
 * @return number of bytes consumed by opcode, used to increase pc.
 */
int
op_iconst_2 (instance * it, void * local_variables_init, void * operand_stack)
  {
    s4 *constant;
#   ifdef DEBUG
    printf("none)");
    fflush(NULL);
#   endif
    
    constant=(s4 *)push_java(sizeof(s4));
    *constant=2;
    
    return 0;
  }

/**
 * Pushes 3 to the stack.
 * @param it caller method instance
 * @param local_variables_init local variable stack init
 * @param operand_stack operand stack init
 * @return number of bytes consumed by opcode, used to increase pc.
 */
int
op_iconst_3 (instance * it, void * local_variables_init, void * operand_stack)
  {
    s4 *constant;
#   ifdef DEBUG
    printf("none)");
    fflush(NULL);
#   endif
    
    constant=(s4 *)push_java(sizeof(s4));
    *constant=3;
    
    return 0;
  }

/**
 * Pushes 4 to the stack.
 * @param it caller method instance
 * @param local_variables_init local variable stack init
 * @param operand_stack operand stack init
 * @return number of bytes consumed by opcode, used to increase pc.
 */
int
op_iconst_4 (instance * it, void * local_variables_init, void * operand_stack)
  {
    s4 *constant;
#   ifdef DEBUG
    printf("none)");
    fflush(NULL);
#   endif
    
    constant=(s4 *)push_java(sizeof(s4));
    *constant=4;
    
    return 0;
  }

/**
 * Pushes 5 to the stack.
 * @param it caller method instance
 * @param local_variables_init local variable stack init
 * @param operand_stack operand stack init
 * @return number of bytes consumed by opcode, used to increase pc.
 */
int
op_iconst_5 (instance * it, void * local_variables_init, void * operand_stack)
  {
    s4 *constant;
#   ifdef DEBUG
    printf("none)");
    fflush(NULL);
#   endif
    
    constant=(s4 *)push_java(sizeof(s4));
    *constant=5;
    
    return 0;
  }

/**
 * Pushes long 0 to the stack.
 * @param it caller method instance
 * @param local_variables_init local variable stack init
 * @param operand_stack operand stack init
 * @return number of bytes consumed by opcode, used to increase pc.
 */
int
op_lconst_0 (instance * it, void * local_variables_init, void * operand_stack)
  {
#   ifdef DEBUG
    printf("none)");
    fflush(NULL);
#   endif

    /* TODO */
    
    return 0;
  }

/**
 * Pushes long 1 to the stack.
 * @param it caller method instance
 * @param local_variables_init local variable stack init
 * @param operand_stack operand stack init
 * @return number of bytes consumed by opcode, used to increase pc.
 */
int
op_lconst_1 (instance * it, void * local_variables_init, void * operand_stack)
  {
#   ifdef DEBUG
    printf("none)");
    fflush(NULL);
#   endif
    
    /* TODO */
    
    return 0;
  }

/**
 * Pushes float 0 to the stack.
 * @param it caller method instance
 * @param local_variables_init local variable stack init
 * @param operand_stack operand stack init
 * @return number of bytes consumed by opcode, used to increase pc.
 */
int
op_fconst_0 (instance * it, void * local_variables_init, void * operand_stack)
  {
#   ifdef DEBUG
    printf("none)");
    fflush(NULL);
#   endif
    
    /* TODO */
    
    return 0;
  }

/**
 * Pushes float 1 to the stack.
 * @param it caller method instance
 * @param local_variables_init local variable stack init
 * @param operand_stack operand stack init
 * @return number of bytes consumed by opcode, used to increase pc.
 */
int
op_fconst_1 (instance * it, void * local_variables_init, void * operand_stack)
  {
#   ifdef DEBUG
    printf("none)");
    fflush(NULL);
#   endif
    
    /* TODO */
    
    return 0;
  }

/**
 * Pushes float 2 to the stack.
 * @param it caller method instance
 * @param local_variables_init local variable stack init
 * @param operand_stack operand stack init
 * @return number of bytes consumed by opcode, used to increase pc.
 */
int
op_fconst_2 (instance * it, void * local_variables_init, void * operand_stack)
  {
#   ifdef DEBUG
    printf("none)");
    fflush(NULL);
#   endif
    
    /* TODO */
    
    return 0;
  }

/**
 * Pushes double 0 to the stack.
 * @param it caller method instance
 * @param local_variables_init local variable stack init
 * @param operand_stack operand stack init
 * @return number of bytes consumed by opcode, used to increase pc.
 */
int
op_dconst_0 (instance * it, void * local_variables_init, void * operand_stack)
  {
#   ifdef DEBUG
    printf("none)");
    fflush(NULL);
#   endif
    
    /* TODO */
    
    return 0;
  }

/**
 * Pushes double 1 to the stack.
 * @param it caller method instance
 * @param local_variables_init local variable stack init
 * @param operand_stack operand stack init
 * @return number of bytes consumed by opcode, used to increase pc.
 */
int
op_dconst_1 (instance * it, void * local_variables_init, void * operand_stack)
  {
#   ifdef DEBUG
    printf("none)");
    fflush(NULL);
#   endif
    
    /* TODO */
    
    return 0;
  }

/**
 * Convert 1 byte signed integer to 4 bytes signed integer and push it into the stack.
 * @param it caller method instance
 * @param local_variables_init local variable stack init
 * @param operand_stack operand stack init
 * @return number of bytes consumed by opcode, used to increase pc.
 */
int
op_bipush (instance * it, void * local_variables_init, void * operand_stack)
  {
    s1 index;
    s4 *integer;
    
    memcpy (&index, getpc() , 1);
#   ifdef DEBUG
    printf("%#.2x)", index);
    fflush(NULL);
#   endif
    
    integer=(s4 *)push_java(sizeof(s4));
    *(integer)=(s4)index;
    
    return 1;
  }

/**
 * Pushes a 2 byte signed integer to the stack.
 * @param it caller method instance
 * @param local_variables_init local variable stack init
 * @param operand_stack operand stack init
 * @return number of bytes consumed by opcode, used to increase pc.
 */
int
op_sipush (instance * it, void * local_variables_init, void * operand_stack)
  {
    s2 index;
    s4 *integer;
    memcpy (&index, getpc() , 2);
    meminv (&index, 2);
#   ifdef DEBUG
    printf("%#.4x)", index);
    fflush(NULL);
#   endif
    
    integer=(s4 *)push_java(sizeof(s4));
    *integer=(int)index;
    
    return 2;
  }

/**
 * Pushes a one word constant to the stack. That can be a int, float or String.
 * The obtained byte is a reference.
 * @param it caller method instance
 * @param local_variables_init local variable stack init
 * @param operand_stack operand stack init
 * @return number of bytes consumed by opcode, used to increase pc.
 */
int
op_ldc (instance * it, void * local_variables_init, void * operand_stack)
  {
    u1 index;
    u1 *string;
    u1 **tops;
    u2 size, position;
    u4 *top;
    
    memcpy (&index, getpc() , 1);
#   ifdef DEBUG
    printf("%#.2x)", index);
    fflush(NULL);
#   endif
    
    if(CONSTANT_Integer==(it->cf->constant_pool+(int)index-1)->tag)
      {
        top=(u4 *)push_java(sizeof(u4));
        memcpy(top,(it->cf->constant_pool+(int)index-1)->info,4);
        meminv(top,4);
      }
    else
      {
        if(CONSTANT_String==(it->cf->constant_pool+(int)index-1)->tag)
          {
            memcpy(&position,(it->cf->constant_pool+(int)index-1)->info,2);
            memcpy(&size,(it->cf->constant_pool+(int)position-1)->info,2);
            string=(u1*)calloc(size+1,sizeof(u1));
            memcpy(string,(it->cf->constant_pool+(int)position-1)->utf8info,size);
            *(string+size)='\0';
            tops=(u1 **)push_java(sizeof(u1*));
            *tops=string;
          }
        else
          {
            /* TODO */
          }
      }
    
    return 1;
  }

/**
 * Same as ldc, wide version.
 * @param it caller method instance
 * @param local_variables_init local variable stack init
 * @param operand_stack operand stack init
 * @return number of bytes consumed by opcode, used to increase pc.
 */
int
op_ldc_w (instance * it, void * local_variables_init, void * operand_stack)
  {
    u2 index;
    memcpy (&index, getpc() , 2);
    meminv (&index, 2);
#   ifdef DEBUG
    printf("%#.4x)", index);
    fflush(NULL);
#   endif
    
    /* TODO */
    
    return 2;
  }

/**
 * Same as lcd_w, but pushes two word constant.
 * @param it caller method instance
 * @param local_variables_init local variable stack init
 * @param operand_stack operand stack init
 * @return number of bytes consumed by opcode, used to increase pc.
 */
int
op_ldc2_w (instance * it, void * local_variables_init, void * operand_stack)
  {
    u2 index;
    memcpy (&index, getpc() , 2);
    meminv (&index, 2);
#   ifdef DEBUG
    printf("%#.4x)", index);
    fflush(NULL);
#   endif
    
    /* TODO */
    
    return 2;
  }

/**
 * Retrieve integer from local variable  and push it in stack.
 * @param it caller method instance
 * @param local_variables_init local variable stack init
 * @param operand_stack operand stack init
 * @return number of bytes consumed by opcode, used to increase pc.
 */
int
op_iload (instance * it, void * local_variables_init, void * operand_stack)
  {
    u1 index;
    u2 index1;
    s4 integer;
    s4 *pinteger;

    if (ISWIDE)
    {
      memcpy (&index1, (u1*)getpc(), 2);
      meminv (&index1, 2);
#     ifdef DEBUG
      printf("%#.4x)", index1);
      fflush(NULL);
#     endif
      
      integer=*((s4*)local_variables_init+(int)index1);
    
      pinteger=(s4 *)push_java(sizeof(s4));
      *pinteger=integer;
      
      return 2;
    }
    else
    {
      memcpy (&index, getpc() , 1);
#     ifdef DEBUG
      printf("%#.2x)", index);
      fflush(NULL);
#     endif
      
      integer=*((s4*)local_variables_init+(int)index);
    
      pinteger=(s4 *)push_java(sizeof(s4));
      *pinteger=integer;
      
      return 1;
    }
  }

/**
 * Retrieve long from local variable.
 * @param it caller method instance
 * @param local_variables_init local variable stack init
 * @param operand_stack operand stack init
 * @return number of bytes consumed by opcode, used to increase pc.
 */
int
op_lload (instance * it, void * local_variables_init, void * operand_stack)
  {
    u1 index;
    u2 index1;

    if (ISWIDE)
    {
      memcpy (&index1, (u1*)getpc(), 2);
      meminv (&index1, 2);
#     ifdef DEBUG
      printf("%#.4x)", index1);
      fflush(NULL);
#     endif
      return 2;
    }
    else
    {
      memcpy (&index, getpc() , 1);
#     ifdef DEBUG
      printf("%#.2x)", index);
      fflush(NULL);
#     endif
      return 1;
    }
    
    /* TODO */
    
  }

/**
 * Retrieve float from local variable.
 * @param it caller method instance
 * @param local_variables_init local variable stack init
 * @param operand_stack operand stack init
 * @return number of bytes consumed by opcode, used to increase pc.
 */
int
op_fload (instance * it, void * local_variables_init, void * operand_stack)
  {
    u1 index;
    u2 index1;

    if (ISWIDE)
    {
      memcpy (&index1, (u1*)getpc(), 2);
      meminv (&index1, 2);
#     ifdef DEBUG
      printf("%#.4x)", index1);
      fflush(NULL);
#     endif
      return 2;
    }
    else
    {
      memcpy (&index, getpc() , 1);
#     ifdef DEBUG
      printf("%#.2x)", index);
      fflush(NULL);
#     endif
      return 1;
    }
    
    /* TODO */
    
  }

/**
 * Retrieve double from local variable.
 * @param it caller method instance
 * @param local_variables_init local variable stack init
 * @param operand_stack operand stack init
 * @return number of bytes consumed by opcode, used to increase pc.
 */
int
op_dload (instance * it, void * local_variables_init, void * operand_stack)
  {
    u1 index;
    u2 index1;

    if (ISWIDE)
    {
      memcpy (&index1, (u1*)getpc(), 2);
      meminv (&index1, 2);
#     ifdef DEBUG
      printf("%#.4x)", index1);
      fflush(NULL);
#     endif
      return 2;
    }
    else
    {
      memcpy (&index, getpc() , 1);
#     ifdef DEBUG
      printf("%#.2x)", index);
      fflush(NULL);
#     endif
      return 1;
    }
    
    /* TODO */
    
  }

/**
 * Retrieve object reference from local variable.
 * @param it caller method instance
 * @param local_variables_init local variable stack init
 * @param operand_stack operand stack init
 * @return number of bytes consumed by opcode, used to increase pc.
 */
int
op_aload (instance * it, void * local_variables_init, void * operand_stack)
  {
    u1 index;
    u2 index1;
    u4 integer;
    u4 *pinteger;

    if (ISWIDE)
    {
      memcpy (&index1, (u1*)getpc(), 2);
      meminv (&index1, 2);
#     ifdef DEBUG
      printf("%#.4x)", index1);
      fflush(NULL);
#     endif
      
      integer=*((u4*)local_variables_init+(int)index1);
    
      pinteger=(u4 *)push_java(sizeof(u4));
      *pinteger=integer;
      
      return 2;
    }
    else
    {
      memcpy (&index, getpc() , 1);
#     ifdef DEBUG
      printf("%#.2x)", index);
      fflush(NULL);
#     endif
      
      integer=*((u4*)local_variables_init+(int)index);
    
      pinteger=(u4 *)push_java(sizeof(u4));
      *pinteger=integer;
      
      return 1;
    }
  }

/**
 * Retrieve integer from local variable 0 and push it in stack.
 * @param it caller method instance
 * @param local_variables_init local variable stack init
 * @param operand_stack operand stack init
 * @return number of bytes consumed by opcode, used to increase pc.
 */
int
op_iload_0 (instance * it, void * local_variables_init, void * operand_stack)
  {
    s4 integer;
    s4 *pinteger;
    
#   ifdef DEBUG
    printf("none)");
    fflush(NULL);
#   endif
    
    integer=*((s4*)local_variables_init);
    
    pinteger=(s4 *)push_java(sizeof(s4));
    *pinteger=integer;
    
    return 0;
  }

/**
 * Retrieve integer from local variable 1 and push it in stack.
 * @param it caller method instance
 * @param local_variables_init local variable stack init
 * @param operand_stack operand stack init
 * @return number of bytes consumed by opcode, used to increase pc.
 */
int
op_iload_1 (instance * it, void * local_variables_init, void * operand_stack)
  {
    s4 integer;
    s4 *pinteger;
    
#   ifdef DEBUG
    printf("none)");
    fflush(NULL);
#   endif
    
    integer=*((s4*)local_variables_init+1);
    
    pinteger=(s4 *)push_java(sizeof(s4));
    *pinteger=integer;
    
    return 0;
  }

/**
 * Retrieve integer from local variable 2 and push it in stack.
 * @param it caller method instance
 * @param local_variables_init local variable stack init
 * @param operand_stack operand stack init
 * @return number of bytes consumed by opcode, used to increase pc.
 */
int
op_iload_2 (instance * it, void * local_variables_init, void * operand_stack)
  {
    s4 integer;
    s4 *pinteger;
    
#   ifdef DEBUG
    printf("none)");
    fflush(NULL);
#   endif
    
    integer=*((s4*)local_variables_init+2);
    
    pinteger=(s4 *)push_java(sizeof(s4));
    *pinteger=integer;
    
    return 0;
  }

/**
 * Retrieve integer from local variable 3 and push it in stack.
 * @param it caller method instance
 * @param local_variables_init local variable stack init
 * @param operand_stack operand stack init
 * @return number of bytes consumed by opcode, used to increase pc.
 */
int
op_iload_3 (instance * it, void * local_variables_init, void * operand_stack)
  {
    s4 integer;
    s4 *pinteger;
    
#   ifdef DEBUG
    printf("none)");
    fflush(NULL);
#   endif
    
    integer=*((s4*)local_variables_init+3);
    
    pinteger=(s4 *)push_java(sizeof(s4));
    *pinteger=integer;
    
    return 0;
  }

/**
 * Retrieve long from local variable 0.
 * @param it caller method instance
 * @param local_variables_init local variable stack init
 * @param operand_stack operand stack init
 * @return number of bytes consumed by opcode, used to increase pc.
 */
int
op_lload_0 (instance * it, void * local_variables_init, void * operand_stack)
  {
#   ifdef DEBUG
    printf("none)");
    fflush(NULL);
#   endif
    
    /* TODO */
    
    return 0;
  }

/**
 * Retrieve long from local variable 1.
 * @param it caller method instance
 * @param local_variables_init local variable stack init
 * @param operand_stack operand stack init
 * @return number of bytes consumed by opcode, used to increase pc.
 */
int
op_lload_1 (instance * it, void * local_variables_init, void * operand_stack)
  {
#   ifdef DEBUG
    printf("none)");
    fflush(NULL);
#   endif
    
    /* TODO */
    
    return 0;
  }

/**
 * Retrieve long from local variable 2.
 * @param it caller method instance
 * @param local_variables_init local variable stack init
 * @param operand_stack operand stack init
 * @return number of bytes consumed by opcode, used to increase pc.
 */
int
op_lload_2 (instance * it, void * local_variables_init, void * operand_stack)
  {
#   ifdef DEBUG
    printf("none)");
    fflush(NULL);
#   endif
    
    /* TODO */
    
    return 0;
  }

/**
 * Retrieve long from local variable 3.
 * @param it caller method instance
 * @param local_variables_init local variable stack init
 * @param operand_stack operand stack init
 * @return number of bytes consumed by opcode, used to increase pc.
 */
int
op_lload_3 (instance * it, void * local_variables_init, void * operand_stack)
  {
#   ifdef DEBUG
    printf("none)");
    fflush(NULL);
#   endif
    
    /* TODO */
    
    return 0;
  }

/**
 * Retrieve float from local variable 0.
 * @param it caller method instance
 * @param local_variables_init local variable stack init
 * @param operand_stack operand stack init
 * @return number of bytes consumed by opcode, used to increase pc.
 */
int
op_fload_0 (instance * it, void * local_variables_init, void * operand_stack)
  {
#   ifdef DEBUG
    printf("none)");
    fflush(NULL);
#   endif
    
    /* TODO */
    
    return 0;
  }

/**
 * Retrieve long from local variable 1.
 * @param it caller method instance
 * @param local_variables_init local variable stack init
 * @param operand_stack operand stack init
 * @return number of bytes consumed by opcode, used to increase pc.
 */
int
op_fload_1 (instance * it, void * local_variables_init, void * operand_stack)
  {
#   ifdef DEBUG
    printf("none)");
    fflush(NULL);
#   endif
    
    /* TODO */
    
    return 0;
  }

/**
 * Retrieve long from local variable 2.
 * @param it caller method instance
 * @param local_variables_init local variable stack init
 * @param operand_stack operand stack init
 * @return number of bytes consumed by opcode, used to increase pc.
 */
int
op_fload_2 (instance * it, void * local_variables_init, void * operand_stack)
  {
#   ifdef DEBUG
    printf("none)");
    fflush(NULL);
#   endif
    
    /* TODO */
    
    return 0;
  }

/**
 * Retrieve long from local variable 3.
 * @param it caller method instance
 * @param local_variables_init local variable stack init
 * @param operand_stack operand stack init
 * @return number of bytes consumed by opcode, used to increase pc.
 */
int
op_fload_3 (instance * it, void * local_variables_init, void * operand_stack)
  {
#   ifdef DEBUG
    printf("none)");
    fflush(NULL);
#   endif
    
    /* TODO */
    
    return 0;
  }

/**
 * Retrieve double from local variable 0.
 * @param it caller method instance
 * @param local_variables_init local variable stack init
 * @param operand_stack operand stack init
 * @return number of bytes consumed by opcode, used to increase pc.
 */
int
op_dload_0 (instance * it, void * local_variables_init, void * operand_stack)
  {
#   ifdef DEBUG
    printf("none)");
    fflush(NULL);
#   endif
    
    /* TODO */
    
    return 0;
  }

/**
 * Retrieve double from local variable 1.
 * @param it caller method instance
 * @param local_variables_init local variable stack init
 * @param operand_stack operand stack init
 * @return number of bytes consumed by opcode, used to increase pc.
 */
int
op_dload_1 (instance * it, void * local_variables_init, void * operand_stack)
  {
#   ifdef DEBUG
    printf("none)");
    fflush(NULL);
#   endif
    
    /* TODO */
    
    return 0;
  }

/**
 * Retrieve double from local variable 2.
 * @param it caller method instance
 * @param local_variables_init local variable stack init
 * @param operand_stack operand stack init
 * @return number of bytes consumed by opcode, used to increase pc.
 */
int
op_dload_2 (instance * it, void * local_variables_init, void * operand_stack)
  {
#   ifdef DEBUG
    printf("none)");
    fflush(NULL);
#   endif
    
    /* TODO */
    
    return 0;
  }

/**
 * Retrieve double from local variable 3.
 * @param it caller method instance
 * @param local_variables_init local variable stack init
 * @param operand_stack operand stack init
 * @return number of bytes consumed by opcode, used to increase pc.
 */
int
op_dload_3 (instance * it, void * local_variables_init, void * operand_stack)
  {
#   ifdef DEBUG
    printf("none)");
    fflush(NULL);
#   endif
    
    /* TODO */
    
    return 0;
  }

/**
 * Retrieve object reference from local variable 0.
 * @param it caller method instance
 * @param local_variables_init local variable stack init
 * @param operand_stack operand stack init
 * @return number of bytes consumed by opcode, used to increase pc.
 */
int
op_aload_0 (instance * it, void * local_variables_init, void * operand_stack)
  {
    u4 integer;
    u4 *pinteger;
    
#   ifdef DEBUG
    printf("none)");
    fflush(NULL);
#   endif
    
    integer=*((u4*)local_variables_init);
    
    pinteger=(u4 *)push_java(sizeof(u4));
    *pinteger=integer;
    
    return 0;
  }

/**
 * Retrieve object reference from local variable 1.
 * @param it caller method instance
 * @param local_variables_init local variable stack init
 * @param operand_stack operand stack init
 * @return number of bytes consumed by opcode, used to increase pc.
 */
int
op_aload_1 (instance * it, void * local_variables_init, void * operand_stack)
  {
    u4 integer;
    u4 *pinteger;
    
#   ifdef DEBUG
    printf("none)");
    fflush(NULL);
#   endif
    
    integer=*((u4*)local_variables_init+1);
    
    pinteger=(u4 *)push_java(sizeof(u4));
    *pinteger=integer;
    
    return 0;
  }

/**
 * Retrieve object reference from local variable 2.
 * @param it caller method instance
 * @param local_variables_init local variable stack init
 * @param operand_stack operand stack init
 * @return number of bytes consumed by opcode, used to increase pc.
 */
int
op_aload_2 (instance * it, void * local_variables_init, void * operand_stack)
  {
    u4 integer;
    u4 *pinteger;
    
#   ifdef DEBUG
    printf("none)");
    fflush(NULL);
#   endif
    
    integer=*((u4*)local_variables_init+2);
    
    pinteger=(u4 *)push_java(sizeof(u4));
    *pinteger=integer;
    
    return 0;
  }

/**
 * Retrieve object reference from local variable 3.
 * @param it caller method instance
 * @param local_variables_init local variable stack init
 * @param operand_stack operand stack init
 * @return number of bytes consumed by opcode, used to increase pc.
 */
int
op_aload_3 (instance * it, void * local_variables_init, void * operand_stack)
  {
    u4 integer;
    u4 *pinteger;
    
#   ifdef DEBUG
    printf("none)");
    fflush(NULL);
#   endif
    
    integer=*((u4*)local_variables_init+3);
    
    pinteger=(u4 *)push_java(sizeof(u4));
    *pinteger=integer;
    
    return 0;
  }

/**
 * Retrieve an integer from an array.
 * @param it caller method instance
 * @param local_variables_init local variable stack init
 * @param operand_stack operand stack init
 * @return number of bytes consumed by opcode, used to increase pc.
 */
int
op_iaload (instance * it, void * local_variables_init, void * operand_stack)
  {
    s4 index;
    s4 *vector, *integer;
#   ifdef DEBUG
    printf("none)");
    fflush(NULL);
#   endif
    
    index=*((s4 *)pop_java(sizeof(s4)));
    vector=(s4 *)pop_java(sizeof(s4));
    
    integer=(s4 *)push_java(sizeof(s4));
    
    *(integer)=*(vector+index);
    
    return 0;
  }

/**
 * Retrieve a long from an array.
 * @param it caller method instance
 * @param local_variables_init local variable stack init
 * @param operand_stack operand stack init
 * @return number of bytes consumed by opcode, used to increase pc.
 */
int
op_laload (instance * it, void * local_variables_init, void * operand_stack)
  {
#   ifdef DEBUG
    printf("none)");
    fflush(NULL);
#   endif
    
    /* TODO */
    
    return 0;
  }

/**
 * Retrieve a float from an array.
 * @param it caller method instance
 * @param local_variables_init local variable stack init
 * @param operand_stack operand stack init
 * @return number of bytes consumed by opcode, used to increase pc.
 */
int
op_faload (instance * it, void * local_variables_init, void * operand_stack)
  {
#   ifdef DEBUG
    printf("none)");
    fflush(NULL);
#   endif
    
    /* TODO */
    
    return 0;
  }

/**
 * Retrieve a double from an array.
 * @param it caller method instance
 * @param local_variables_init local variable stack init
 * @param operand_stack operand stack init
 * @return number of bytes consumed by opcode, used to increase pc.
 */
int
op_daload (instance * it, void * local_variables_init, void * operand_stack)
  {
#   ifdef DEBUG
    printf("none)");
    fflush(NULL);
#   endif
    
    /* TODO */
    
    return 0;
  }

/**
 * Retrieve an object reference from an array.
 * @param it caller method instance
 * @param local_variables_init local variable stack init
 * @param operand_stack operand stack init
 * @return number of bytes consumed by opcode, used to increase pc.
 */
int
op_aaload (instance * it, void * local_variables_init, void * operand_stack)
  {
    u4 index;
    u4 *vector, *integer;
#   ifdef DEBUG
    printf("none)");
    fflush(NULL);
#   endif
    
    index=*((u4 *)pop_java(sizeof(u4)));
    vector=(u4 *)pop_java(sizeof(u4));
    
    integer=(u4 *)push_java(sizeof(u4));
    
    *(integer)=*(vector+index);
    
    return 0;
  }

/**
 * Retrieve a byte from an array.
 * @param it caller method instance
 * @param local_variables_init local variable stack init
 * @param operand_stack operand stack init
 * @return number of bytes consumed by opcode, used to increase pc.
 */
int
op_baload (instance * it, void * local_variables_init, void * operand_stack)
  {
#   ifdef DEBUG
    printf("none)");
    fflush(NULL);
#   endif
    
    /* TODO */
    
    return 0;
  }

/**
 * Retrieve a character from an array.
 * @param it caller method instance
 * @param local_variables_init local variable stack init
 * @param operand_stack operand stack init
 * @return number of bytes consumed by opcode, used to increase pc.
 */
int
op_caload (instance * it, void * local_variables_init, void * operand_stack)
  {
#   ifdef DEBUG
    printf("none)");
    fflush(NULL);
#   endif
    
    /* TODO */
    
    return 0;
  }

/**
 * Retrieve a short from an array.
 * @param it caller method instance
 * @param local_variables_init local variable stack init
 * @param operand_stack operand stack init
 * @return number of bytes consumed by opcode, used to increase pc.
 */
int
op_saload (instance * it, void * local_variables_init, void * operand_stack)
  {
#   ifdef DEBUG
    printf("none)");
    fflush(NULL);
#   endif
    
    /* TODO */
    
    return 0;
  }

/**
 * Pop a interger and store it in local variable.
 * @param it caller method instance
 * @param local_variables_init local variable stack init
 * @param operand_stack operand stack init
 * @return number of bytes consumed by opcode, used to increase pc.
 */
int
op_istore (instance * it, void * local_variables_init, void * operand_stack)
  {
    u1 index;
    u2 index1;
    s4 integer;
    
    integer=*((s4*)pop_java(sizeof(s4)));
    
    if (ISWIDE)
      {
        memcpy (&index1, (u1*)getpc(), 2);
        meminv (&index1, 2);
#       ifdef DEBUG
        printf("%#.4x)", index1);
        fflush(NULL);
#       endif
        
        *((s4*)local_variables_init+(int)index1)=integer;
        
        return 2;
      }
    else
      {
        memcpy (&index, getpc() , 1);
#       ifdef DEBUG
        printf("%#.2x)", index);
        fflush(NULL);
#       endif
        
        *((s4*)local_variables_init+(int)index)=integer;
        
        return 1;
      }
  }

/**
 * Store long in local variable.
 * @param it caller method instance
 * @param local_variables_init local variable stack init
 * @param operand_stack operand stack init
 * @return number of bytes consumed by opcode, used to increase pc.
 */
int
op_lstore (instance * it, void * local_variables_init, void * operand_stack)
  {
    u1 index;
    u2 index1;

    if (ISWIDE)
    {
      memcpy (&index1, (u1*)getpc(), 2);
      meminv (&index1, 2);
#     ifdef DEBUG
      printf("%#.4x)", index1);
      fflush(NULL);
#     endif
      return 2;
    }
    else
    {
      memcpy (&index, getpc() , 1);
#     ifdef DEBUG
      printf("%#.2x)", index);
      fflush(NULL);
#     endif
      return 1;
    }
    
    /* TODO */
    
  }

/**
 * Store float in local variable.
 * @param it caller method instance
 * @param local_variables_init local variable stack init
 * @param operand_stack operand stack init
 * @return number of bytes consumed by opcode, used to increase pc.
 */
int
op_fstore (instance * it, void * local_variables_init, void * operand_stack)
  {
    u1 index;
    u2 index1;

    if (ISWIDE)
    {
      memcpy (&index1, (u1*)getpc(), 2);
      meminv (&index1, 2);
#     ifdef DEBUG
      printf("%#.4x)", index1);
      fflush(NULL);
#     endif
      return 2;
    }
    else
    {
      memcpy (&index, getpc() , 1);
#     ifdef DEBUG
      printf("%#.2x)", index);
      fflush(NULL);
#     endif
      return 1;
    }
    
    /* TODO */
    
  }

/**
 * Store double in local variable.
 * @param it caller method instance
 * @param local_variables_init local variable stack init
 * @param operand_stack operand stack init
 * @return number of bytes consumed by opcode, used to increase pc.
 */
int
op_dstore (instance * it, void * local_variables_init, void * operand_stack)
  {
    u1 index;
    u2 index1;

    if (ISWIDE)
    {
      memcpy (&index1, (u1*)getpc(), 2);
      meminv (&index1, 2);
#     ifdef DEBUG
      printf("%#.4x)", index1);
      fflush(NULL);
#     endif
      return 2;
    }
    else
    {
      memcpy (&index, getpc() , 1);
#     ifdef DEBUG
      printf("%#.2x)", index);
      fflush(NULL);
#     endif
      return 1;
    }
    
    /* TODO */
    
  }

/**
 * Store object reference in local variable.
 * @param it caller method instance
 * @param local_variables_init local variable stack init
 * @param operand_stack operand stack init
 * @return number of bytes consumed by opcode, used to increase pc.
 */
int
op_astore (instance * it, void * local_variables_init, void * operand_stack)
  {
    u1 index;
    u2 index1;
    u4 integer;
    
    integer=*((u4*)pop_java(sizeof(u4)));
    
    if (ISWIDE)
    {
      memcpy (&index1, (u1*)getpc(), 2);
      meminv (&index1, 2);
#     ifdef DEBUG
      printf("%#.4x)", index1);
      fflush(NULL);
#     endif
        
      *((u4*)local_variables_init+(int)index1)=integer;
        
      return 2;
    }
    else
    {
      memcpy (&index, getpc() , 1);
#     ifdef DEBUG
      printf("%#.2x)", index);
      fflush(NULL);
#     endif
        
      *((u4*)local_variables_init+(int)index)=integer;
        
      return 1;
    }
  }

/**
 * Pop a interger and store it in local variable 0.
 * @param it caller method instance
 * @param local_variables_init local variable stack init
 * @param operand_stack operand stack init
 * @return number of bytes consumed by opcode, used to increase pc.
 */
int
op_istore_0 (instance * it, void * local_variables_init, void * operand_stack)
  {
    s4 integer;
#   ifdef DEBUG
    printf("none)");
    fflush(NULL);
#   endif
    
    integer=*((s4*)pop_java(sizeof(s4)));
    
    *((s4*)local_variables_init)=integer;
    
    return 0;
  }

/**
   * Pop a interger and store it in local variable 1.
 * @param it caller method instance
 * @param local_variables_init local variable stack init
 * @param operand_stack operand stack init
 * @return number of bytes consumed by opcode, used to increase pc.
 */
int
op_istore_1 (instance * it, void * local_variables_init, void * operand_stack)
  {
    s4 integer;
#   ifdef DEBUG
    printf("none)");
    fflush(NULL);
#   endif
    
    integer=*((s4*)pop_java(sizeof(s4)));
    
    *((s4*)local_variables_init+1)=integer;
    
    return 0;
  }

/**
 * Pop a interger and store it in local variable 2.
 * @param it caller method instance
 * @param local_variables_init local variable stack init
 * @param operand_stack operand stack init
 * @return number of bytes consumed by opcode, used to increase pc.
 */
int
op_istore_2 (instance * it, void * local_variables_init, void * operand_stack)
  {
    s4 integer;
#   ifdef DEBUG
    printf("none)");
    fflush(NULL);
#   endif
    
    integer=*((s4*)pop_java(sizeof(s4)));
    
    *((s4*)local_variables_init+2)=integer;
    
    return 0;
  }

/**
 * Pop a interger and store it in local variable 3.
 * @param it caller method instance
 * @param local_variables_init local variable stack init
 * @param operand_stack operand stack init
 * @return number of bytes consumed by opcode, used to increase pc.
 */
int
op_istore_3 (instance * it, void * local_variables_init, void * operand_stack)
  {
    s4 integer;
#   ifdef DEBUG
    printf("none)");
    fflush(NULL);
#   endif
    
    integer=*((s4*)pop_java(sizeof(s4)));
    
    *((s4*)local_variables_init+3)=integer;
    
    return 0;
  }

/**
 * Store long in local variable 0.
 * @param it caller method instance
 * @param local_variables_init local variable stack init
 * @param operand_stack operand stack init
 * @return number of bytes consumed by opcode, used to increase pc.
 */
int
op_lstore_0 (instance * it, void * local_variables_init, void * operand_stack)
  {
#   ifdef DEBUG
    printf("none)");
    fflush(NULL);
#   endif
    
    /* TODO */
    
    return 0;
  }

/**
 * Store long in local variable 1.
 * @param it caller method instance
 * @param local_variables_init local variable stack init
 * @param operand_stack operand stack init
 * @return number of bytes consumed by opcode, used to increase pc.
 */
int
op_lstore_1 (instance * it, void * local_variables_init, void * operand_stack)
  {
#   ifdef DEBUG
    printf("none)");
    fflush(NULL);
#   endif
    
    /* TODO */
    
    return 0;
  }

/**
 * Store long in local variable 2.
 * @param it caller method instance
 * @param local_variables_init local variable stack init
 * @param operand_stack operand stack init
 * @return number of bytes consumed by opcode, used to increase pc.
 */
int
op_lstore_2 (instance * it, void * local_variables_init, void * operand_stack)
  {
#   ifdef DEBUG
    printf("none)");
    fflush(NULL);
#   endif
    
    /* TODO */
    
    return 0;
  }

/**
 * Store long in local variable 3.
 * @param it caller method instance
 * @param local_variables_init local variable stack init
 * @param operand_stack operand stack init
 * @return number of bytes consumed by opcode, used to increase pc.
 */
int
op_lstore_3 (instance * it, void * local_variables_init, void * operand_stack)
  {
#   ifdef DEBUG
    printf("none)");
    fflush(NULL);
#   endif
    
    /* TODO */
    
    return 0;
  }

/**
 * Store float in local variable 0.
 * @param it caller method instance
 * @param local_variables_init local variable stack init
 * @param operand_stack operand stack init
 * @return number of bytes consumed by opcode, used to increase pc.
 */
int
op_fstore_0 (instance * it, void * local_variables_init, void * operand_stack)
  {
#   ifdef DEBUG
    printf("none)");
    fflush(NULL);
#   endif
    
    /* TODO */
    
    return 0;
  }

/**
 * Store float in local variable 1.
 * @param it caller method instance
 * @param local_variables_init local variable stack init
 * @param operand_stack operand stack init
 * @return number of bytes consumed by opcode, used to increase pc.
 */
int
op_fstore_1 (instance * it, void * local_variables_init, void * operand_stack)
  {
#   ifdef DEBUG
    printf("none)");
    fflush(NULL);
#   endif
    
    /* TODO */
    
    return 0;
  }

/**
 * Store float in local variable 2.
 * @param it caller method instance
 * @param local_variables_init local variable stack init
 * @param operand_stack operand stack init
 * @return number of bytes consumed by opcode, used to increase pc.
 */
int
op_fstore_2 (instance * it, void * local_variables_init, void * operand_stack)
  {
#   ifdef DEBUG
    printf("none)");
    fflush(NULL);
#   endif
    
    /* TODO */
    
    return 0;
  }

/**
 * Store float in local variable 3.
 * @param it caller method instance
 * @param local_variables_init local variable stack init
 * @param operand_stack operand stack init
 * @return number of bytes consumed by opcode, used to increase pc.
 */
int
op_fstore_3 (instance * it, void * local_variables_init, void * operand_stack)
  {
#   ifdef DEBUG
    printf("none)");
    fflush(NULL);
#   endif
    
    /* TODO */
    
    return 0;
  }

/**
 * Store double in local variable 0.
 * @param it caller method instance
 * @param local_variables_init local variable stack init
 * @param operand_stack operand stack init
 * @return number of bytes consumed by opcode, used to increase pc.
 */
int
op_dstore_0 (instance * it, void * local_variables_init, void * operand_stack)
  {
#   ifdef DEBUG
    printf("none)");
    fflush(NULL);
#   endif
    
    /* TODO */
    
    return 0;
  }

/**
 * Store double in local variable 1.
 * @param it caller method instance
 * @param local_variables_init local variable stack init
 * @param operand_stack operand stack init
 * @return number of bytes consumed by opcode, used to increase pc.
 */
int
op_dstore_1 (instance * it, void * local_variables_init, void * operand_stack)
  {
#   ifdef DEBUG
    printf("none)");
    fflush(NULL);
#   endif
    
    /* TODO */
    
    return 0;
  }

/**
 * Store double in local variable 2.
 * @param it caller method instance
 * @param local_variables_init local variable stack init
 * @param operand_stack operand stack init
 * @return number of bytes consumed by opcode, used to increase pc.
 */
int
op_dstore_2 (instance * it, void * local_variables_init, void * operand_stack)
  {
#   ifdef DEBUG
    printf("none)");
    fflush(NULL);
#   endif
    
    /* TODO */
    
    return 0;
  }

/**
 * Store double in local variable 3.
 * @param it caller method instance
 * @param local_variables_init local variable stack init
 * @param operand_stack operand stack init
 * @return number of bytes consumed by opcode, used to increase pc.
 */
int
op_dstore_3 (instance * it, void * local_variables_init, void * operand_stack)
  {
#   ifdef DEBUG
    printf("none)");
    fflush(NULL);
#   endif
    
    /* TODO */
    
    return 0;
  }

/**
 * Store object reference in local variable 0.
 * @param it caller method instance
 * @param local_variables_init local variable stack init
 * @param operand_stack operand stack init
 * @return number of bytes consumed by opcode, used to increase pc.
 */
int
op_astore_0 (instance * it, void * local_variables_init, void * operand_stack)
  {
    u4 integer;
#   ifdef DEBUG
    printf("none)");
    fflush(NULL);
#   endif
    
    integer=*((u4*)pop_java(sizeof(u4)));
    
    *((u4*)local_variables_init)=integer;
    
    return 0;
  }

/**
 * Store object reference in local variable 1.
 * @param it caller method instance
 * @param local_variables_init local variable stack init
 * @param operand_stack operand stack init
 * @return number of bytes consumed by opcode, used to increase pc.
 */
int
op_astore_1 (instance * it, void * local_variables_init, void * operand_stack)
  {
    u4 integer;
#   ifdef DEBUG
    printf("none)");
    fflush(NULL);
#   endif
    
    integer=*((u4*)pop_java(sizeof(u4)));
    
    *((u4*)local_variables_init+1)=integer;
    
    return 0;
  }

/**
 * Store object reference in local variable 2.
 * @param it caller method instance
 * @param local_variables_init local variable stack init
 * @param operand_stack operand stack init
 * @return number of bytes consumed by opcode, used to increase pc.
 */
int
op_astore_2 (instance * it, void * local_variables_init, void * operand_stack)
  {
    u4 integer;
#   ifdef DEBUG
    printf("none)");
    fflush(NULL);
#   endif
    
    integer=*((u4*)pop_java(sizeof(u4)));
    
    *((u4*)local_variables_init+2)=integer;
    
    return 0;
  }

/**
 * Store object reference in local variable 3.
 * @param it caller method instance
 * @param local_variables_init local variable stack init
 * @param operand_stack operand stack init
 * @return number of bytes consumed by opcode, used to increase pc.
 */
int
op_astore_3 (instance * it, void * local_variables_init, void * operand_stack)
  {
    u4 integer;
#   ifdef DEBUG
    printf("none)");
    fflush(NULL);
#   endif
    
    integer=*((u4*)pop_java(sizeof(u4)));
    
    *((u4*)local_variables_init+3)=integer;
    
    return 0;
  }

/**
 * Store integer in array.
 * @param it caller method instance
 * @param local_variables_init local variable stack init
 * @param operand_stack operand stack init
 * @return number of bytes consumed by opcode, used to increase pc.
 */
int
op_iastore (instance * it, void * local_variables_init, void * operand_stack)
  {
    s4 integer, index;
    s4 *vector;
#   ifdef DEBUG
    printf("none)");
    fflush(NULL);
#   endif
    
    integer=*((s4 *)pop_java(sizeof(s4)));
    index=*((s4 *)pop_java(sizeof(s4)));
    vector=(s4 *)pop_java(sizeof(s4));
    
    *(vector+index)=integer;
    
    return 0;
  }

/**
 * Store long in array.
 * @param it caller method instance
 * @param local_variables_init local variable stack init
 * @param operand_stack operand stack init
 * @return number of bytes consumed by opcode, used to increase pc.
 */
int
op_lastore (instance * it, void * local_variables_init, void * operand_stack)
  {
#   ifdef DEBUG
    printf("none)");
    fflush(NULL);
#   endif
    
    /* TODO */
    
    return 0;
  }

/**
 * Store float in array.
 * @param it caller method instance
 * @param local_variables_init local variable stack init
 * @param operand_stack operand stack init
 * @return number of bytes consumed by opcode, used to increase pc.
 */
int
op_fastore (instance * it, void * local_variables_init, void * operand_stack)
  {
#   ifdef DEBUG
    printf("none)");
    fflush(NULL);
#   endif
    
    /* TODO */
    
    return 0;
  }

/**
 * Store double in array.
 * @param it caller method instance
 * @param local_variables_init local variable stack init
 * @param operand_stack operand stack init
 * @return number of bytes consumed by opcode, used to increase pc.
 */
int
op_dastore (instance * it, void * local_variables_init, void * operand_stack)
  {
#   ifdef DEBUG
    printf("none)");
    fflush(NULL);
#   endif
    
    /* TODO */
    
    return 0;
  }

/**
 * Store object reference in array.
 * @param it caller method instance
 * @param local_variables_init local variable stack init
 * @param operand_stack operand stack init
 * @return number of bytes consumed by opcode, used to increase pc.
 */
int
op_aastore (instance * it, void * local_variables_init, void * operand_stack)
  {
    u4 integer, index;
    u4 *vector;
#   ifdef DEBUG
    printf("none)");
    fflush(NULL);
#   endif
    
    integer=*((u4 *)pop_java(sizeof(u4)));
    index=*((u4 *)pop_java(sizeof(u4)));
    vector=(u4 *)pop_java(sizeof(u4));
    
    *(vector+index)=integer;
    
    return 0;
  }

/**
 * Store byte in array.
 * @param it caller method instance
 * @param local_variables_init local variable stack init
 * @param operand_stack operand stack init
 * @return number of bytes consumed by opcode, used to increase pc.
 */
int
op_bastore (instance * it, void * local_variables_init, void * operand_stack)
  {
#   ifdef DEBUG
    printf("none)");
    fflush(NULL);
#   endif
    
    /* TODO */
    
    return 0;
  }

/**
 * Store character in array.
 * @param it caller method instance
 * @param local_variables_init local variable stack init
 * @param operand_stack operand stack init
 * @return number of bytes consumed by opcode, used to increase pc.
 */
int
op_castore (instance * it, void * local_variables_init, void * operand_stack)
  {
#   ifdef DEBUG
    printf("none)");
    fflush(NULL);
#   endif
    
    /* TODO */
    
    return 0;
  }

/**
 * Store short int in array.
 * @param it caller method instance
 * @param local_variables_init local variable stack init
 * @param operand_stack operand stack init
 * @return number of bytes consumed by opcode, used to increase pc.
 */
int
op_sastore (instance * it, void * local_variables_init, void * operand_stack)
  {
#   ifdef DEBUG
    printf("none)");
    fflush(NULL);
#   endif
    
    /* TODO */
    
    return 0;
  }

/**
 * Discard top word of stack.
 * @param it caller method instance
 * @param local_variables_init local variable stack init
 * @param operand_stack operand stack init
 * @return number of bytes consumed by opcode, used to increase pc.
 */
int
op_pop (instance * it, void * local_variables_init, void * operand_stack)
  {
#   ifdef DEBUG
    printf("none)");
    fflush(NULL);
#   endif
    
    pop_java(sizeof(s4));
    
    return 0;
  }

/**
 * Discard two words of stack.
 * @param it caller method instance
 * @param local_variables_init local variable stack init
 * @param operand_stack operand stack init
 * @return number of bytes consumed by opcode, used to increase pc.
 */
int
op_pop2 (instance * it, void * local_variables_init, void * operand_stack)
  {
#   ifdef DEBUG
    printf("none)");
    fflush(NULL);
#   endif
    
    pop_java(2*sizeof(s4));
    
    return 0;
  }

/**
 * Duplicate the top word of stack.
 * @param it caller method instance
 * @param local_variables_init local variable stack init
 * @param operand_stack operand stack init
 * @return number of bytes consumed by opcode, used to increase pc.
 */
int
op_dup (instance * it, void * local_variables_init, void * operand_stack)
  {
    s4 *top;
#   ifdef DEBUG
    printf("none)");
    fflush(NULL);
#   endif
    
    top=(s4 *)push_java(sizeof(s4));
    *top=*(top-1);
    
    return 0;
  }

/**
 * Duplicate the top word of stack and inserts after the first word.
 * @param it caller method instance
 * @param local_variables_init local variable stack init
 * @param operand_stack operand stack init
 * @return number of bytes consumed by opcode, used to increase pc.
 */
int
op_dup_x1 (instance * it, void * local_variables_init, void * operand_stack)
  {
    s4 *top;
#   ifdef DEBUG
    printf("none)");
    fflush(NULL);
#   endif
    
    top=(s4 *)push_java(sizeof(s4));
    *top=*(top-1);
    *(top-1)=*(top-2);
    *(top-2)=*top;
    
    return 0;
  }

/**
 * Duplicate the top word of stack and inserts after the second word.
 * @param it caller method instance
 * @param local_variables_init local variable stack init
 * @param operand_stack operand stack init
 * @return number of bytes consumed by opcode, used to increase pc.
 */
int
op_dup_x2 (instance * it, void * local_variables_init, void * operand_stack)
  {
    s4 *top;
#   ifdef DEBUG
    printf("none)");
    fflush(NULL);
#   endif
    
    top=(s4 *)push_java(sizeof(s4));
    *top=*(top-1);
    *(top-1)=*(top-2);
    *(top-2)=*(top-3);
    *(top-3)=*top;
    
    return 0;
  }

/**
 * Duplicate the top two words of stack.
 * @param it caller method instance
 * @param local_variables_init local variable stack init
 * @param operand_stack operand stack init
 * @return number of bytes consumed by opcode, used to increase pc.
 */
int
op_dup2 (instance * it, void * local_variables_init, void * operand_stack)
  {
    s4 *top;
#   ifdef DEBUG
    printf("none)");
    fflush(NULL);
#   endif
    
    top=(s4 *)push_java(2*sizeof(s4));
    *top=*(top-2);
    *(top+1)=*(top-1);
    
    return 0;
  }

/**
 * Duplicate the top two words of stack and inserts after the first word.
 * @param it caller method instance
 * @param local_variables_init local variable stack init
 * @param operand_stack operand stack init
 * @return number of bytes consumed by opcode, used to increase pc.
 */
int
op_dup2_x1 (instance * it, void * local_variables_init, void * operand_stack)
  {
    s4 *top;
#   ifdef DEBUG
    printf("none)");
    fflush(NULL);
#   endif
    
    top=(s4 *)push_java(2*sizeof(s4));
    *(top+1)=*(top-1);
    *top=*(top-2);
    *(top-1)=*(top-3);
    *(top-2)=*(top+1);
    *(top-3)=*top;
    
    return 0;
  }

/**
 * Duplicate the top two words of stack and inserts after the second word.
 * @param it caller method instance
 * @param local_variables_init local variable stack init
 * @param operand_stack operand stack init
 * @return number of bytes consumed by opcode, used to increase pc.
 */
int
op_dup2_x2 (instance * it, void * local_variables_init, void * operand_stack)
  {
    s4 *top;
#   ifdef DEBUG
    printf("none)");
    fflush(NULL);
#   endif
    
    top=(s4 *)push_java(2*sizeof(s4));
    *(top+1)=*(top-1);
    *top=*(top-2);
    *(top-1)=*(top-3);
    *(top-2)=*(top-4);
    *(top-3)=*(top+1);
    *(top-4)=*top;
    
    return 0;
  }

/**
 * Swap the top words of the stack.
 * @param it caller method instance
 * @param local_variables_init local variable stack init
 * @param operand_stack operand stack init
 * @return number of bytes consumed by opcode, used to increase pc.
 */
int
op_swap (instance * it, void * local_variables_init, void * operand_stack)
  {
    s4 temp;
    s4 *top;
#   ifdef DEBUG
    printf("none)");
    fflush(NULL);
#   endif
    
    top=(s4 *)getsp_java();
    temp=*(top-1);
    *(top-1)=*(top-2);
    *(top-2)=temp;
    
    return 0;
  }

/**
 * Add two integers.
 * @param it caller method instance
 * @param local_variables_init local variable stack init
 * @param operand_stack operand stack init
 * @return number of bytes consumed by opcode, used to increase pc.
 */
int
op_iadd (instance * it, void * local_variables_init, void * operand_stack)
  {
    s4 *top;
#   ifdef DEBUG
    printf("none)");
    fflush(NULL);
#   endif

    top=(s4 *)pop_java(sizeof(s4));
    *(top-1)=*(top-1)+*top;

    return 0;
  }

/**
 * Add two long.
 * @param it caller method instance
 * @param local_variables_init local variable stack init
 * @param operand_stack operand stack init
 * @return number of bytes consumed by opcode, used to increase pc.
 */
int
op_ladd (instance * it, void * local_variables_init, void * operand_stack)
  {
#   ifdef DEBUG
    printf("none)");
    fflush(NULL);
#   endif
    
    /* TODO */
    
    return 0;
  }

/**
 * Add two float.
 * @param it caller method instance
 * @param local_variables_init local variable stack init
 * @param operand_stack operand stack init
 * @return number of bytes consumed by opcode, used to increase pc.
 */
int
op_fadd (instance * it, void * local_variables_init, void * operand_stack)
  {
#   ifdef DEBUG
    printf("none)");
    fflush(NULL);
#   endif
    
    /* TODO */
    
    return 0;
  }

/**
 * Add two doubles.
 * @param it caller method instance
 * @param local_variables_init local variable stack init
 * @param operand_stack operand stack init
 * @return number of bytes consumed by opcode, used to increase pc.
 */
int
op_dadd (instance * it, void * local_variables_init, void * operand_stack)
  {
#   ifdef DEBUG
    printf("none)");
    fflush(NULL);
#   endif
    
    /* TODO */
    
    return 0;
  }

/**
 * Subtract two integers.
 * @param it caller method instance
 * @param local_variables_init local variable stack init
 * @param operand_stack operand stack init
 * @return number of bytes consumed by opcode, used to increase pc.
 */
int
op_isub (instance * it, void * local_variables_init, void * operand_stack)
  {
    s4 *top;
#   ifdef DEBUG
    printf("none)");
    fflush(NULL);
#   endif
    
    top=(s4 *)pop_java(sizeof(s4));
    *(top-1)=*(top-1)-*top;
    
    return 0;
  }

/**
 * Subtract two longs.
 * @param it caller method instance
 * @param local_variables_init local variable stack init
 * @param operand_stack operand stack init
 * @return number of bytes consumed by opcode, used to increase pc.
 */
int
op_lsub (instance * it, void * local_variables_init, void * operand_stack)
  {
#   ifdef DEBUG
    printf("none)");
    fflush(NULL);
#   endif
    
    /* TODO */
    
    return 0;
  }

/**
 * Subtract two float.
 * @param it caller method instance
 * @param local_variables_init local variable stack init
 * @param operand_stack operand stack init
 * @return number of bytes consumed by opcode, used to increase pc.
 */
int
op_fsub (instance * it, void * local_variables_init, void * operand_stack)
  {
#   ifdef DEBUG
    printf("none)");
    fflush(NULL);
#   endif
    
    /* TODO */
    
    return 0;
  }

/**
 * Subtract two doubles.
 * @param it caller method instance
 * @param local_variables_init local variable stack init
 * @param operand_stack operand stack init
 * @return number of bytes consumed by opcode, used to increase pc.
 */
int
op_dsub (instance * it, void * local_variables_init, void * operand_stack)
  {
#   ifdef DEBUG
    printf("none)");
    fflush(NULL);
#   endif
    
    /* TODO */
    
    return 0;
  }

/**
 * Multiplies two integers.
 * @param it caller method instance
 * @param local_variables_init local variable stack init
 * @param operand_stack operand stack init
 * @return number of bytes consumed by opcode, used to increase pc.
 */
int
op_imul (instance * it, void * local_variables_init, void * operand_stack)
  {
    s4 *top;
#   ifdef DEBUG
    printf("none)");
    fflush(NULL);
#   endif
    
    top=(s4 *)pop_java(sizeof(s4));
    *(top-1)=*(top-1)**top;
    
    return 0;
  }

/**
 * Multiplies two longs.
 * @param it caller method instance
 * @param local_variables_init local variable stack init
 * @param operand_stack operand stack init
 * @return number of bytes consumed by opcode, used to increase pc.
 */
int
op_lmul (instance * it, void * local_variables_init, void * operand_stack)
  {
#   ifdef DEBUG
    printf("none)");
    fflush(NULL);
#   endif
    
    /* TODO */
    
    return 0;
  }

/**
 * Multiplies two floats.
 * @param it caller method instance
 * @param local_variables_init local variable stack init
 * @param operand_stack operand stack init
 * @return number of bytes consumed by opcode, used to increase pc.
 */
int
op_fmul (instance * it, void * local_variables_init, void * operand_stack)
  {
#   ifdef DEBUG
    printf("none)");
    fflush(NULL);
#   endif
    
    /* TODO */
    
    return 0;
  }

/**
 * Multiplies two doubles.
 * @param it caller method instance
 * @param local_variables_init local variable stack init
 * @param operand_stack operand stack init
 * @return number of bytes consumed by opcode, used to increase pc.
 */
int
op_dmul (instance * it, void * local_variables_init, void * operand_stack)
  {
#   ifdef DEBUG
    printf("none)");
    fflush(NULL);
#   endif
    
    /* TODO */
    
    return 0;
  }

/**
 * Divides two integers.
 * @param it caller method instance
 * @param local_variables_init local variable stack init
 * @param operand_stack operand stack init
 * @return number of bytes consumed by opcode, used to increase pc.
 */
int
op_idiv (instance * it, void * local_variables_init, void * operand_stack)
  {
    s4 *top;
#   ifdef DEBUG
    printf("none)");
    fflush(NULL);
#   endif
    
    top=(s4 *)pop_java(sizeof(s4));
    *(top-1)=*(top-1)/(*top);
    
    return 0;
  }

/**
 * Divides two longs.
 * @param it caller method instance
 * @param local_variables_init local variable stack init
 * @param operand_stack operand stack init
 * @return number of bytes consumed by opcode, used to increase pc.
 */
int
op_ldiv (instance * it, void * local_variables_init, void * operand_stack)
  {
#   ifdef DEBUG
    printf("none)");
    fflush(NULL);
#   endif
    
    /* TODO */
    
    return 0;
  }

/**
 * Divides two floats.
 * @param it caller method instance
 * @param local_variables_init local variable stack init
 * @param operand_stack operand stack init
 * @return number of bytes consumed by opcode, used to increase pc.
 */
int
op_fdiv (instance * it, void * local_variables_init, void * operand_stack)
  {
#   ifdef DEBUG
    printf("none)");
    fflush(NULL);
#   endif
    
    /* TODO */
    
    return 0;
  }

/**
 * Divides two doubles.
 * @param it caller method instance
 * @param local_variables_init local variable stack init
 * @param operand_stack operand stack init
 * @return number of bytes consumed by opcode, used to increase pc.
 */
int
op_ddiv (instance * it, void * local_variables_init, void * operand_stack)
  {
#   ifdef DEBUG
    printf("none)");
    fflush(NULL);
#   endif
    
    /* TODO */
    
    return 0;
  }

/**
 * Remainder of two integers.
 * @param it caller method instance
 * @param local_variables_init local variable stack init
 * @param operand_stack operand stack init
 * @return number of bytes consumed by opcode, used to increase pc.
 */
int
op_irem (instance * it, void * local_variables_init, void * operand_stack)
  {
    s4 *top;
#   ifdef DEBUG
    printf("none)");
    fflush(NULL);
#   endif
    
    top=(s4 *)pop_java(sizeof(s4));
    *(top-1)=*(top-1)%(*top);
    
    return 0;
  }

/**
 * Remainder of two longs.
 * @param it caller method instance
 * @param local_variables_init local variable stack init
 * @param operand_stack operand stack init
 * @return number of bytes consumed by opcode, used to increase pc.
 */
int
op_lrem (instance * it, void * local_variables_init, void * operand_stack)
  {
#   ifdef DEBUG
    printf("none)");
    fflush(NULL);
#   endif
    
    /* TODO */
    
    return 0;
  }

/**
 * Remainder of two floats.
 * @param it caller method instance
 * @param local_variables_init local variable stack init
 * @param operand_stack operand stack init
 * @return number of bytes consumed by opcode, used to increase pc.
 */
int
op_frem (instance * it, void * local_variables_init, void * operand_stack)
  {
#   ifdef DEBUG
    printf("none)");
    fflush(NULL);
#   endif
    
    /* TODO */
    
    return 0;
  }

/**
 * Remainder of two doubles.
 * @param it caller method instance
 * @param local_variables_init local variable stack init
 * @param operand_stack operand stack init
 * @return number of bytes consumed by opcode, used to increase pc.
 */
int
op_drem (instance * it, void * local_variables_init, void * operand_stack)
  {
#   ifdef DEBUG
    printf("none)");
    fflush(NULL);
#   endif
    
    /* TODO */
    
    return 0;
  }

/**
 * Negativate an integer.
 * @param it caller method instance
 * @param local_variables_init local variable stack init
 * @param operand_stack operand stack init
 * @return number of bytes consumed by opcode, used to increase pc.
 */
int
op_ineg (instance * it, void * local_variables_init, void * operand_stack)
  {
    s4 *top;
#   ifdef DEBUG
    printf("none)");
    fflush(NULL);
#   endif
    
    top=(s4 *)getsp_java();
    *(top-1)=-*(top-1);
    
    return 0;
  }

/**
 * Negativate a long.
 * @param it caller method instance
 * @param local_variables_init local variable stack init
 * @param operand_stack operand stack init
 * @return number of bytes consumed by opcode, used to increase pc.
 */
int
op_lneg (instance * it, void * local_variables_init, void * operand_stack)
  {
#   ifdef DEBUG
    printf("none)");
    fflush(NULL);
#   endif
    
    /* TODO */
    
    return 0;
  }

/**
 * Negativate a float.
 * @param it caller method instance
 * @param local_variables_init local variable stack init
 * @param operand_stack operand stack init
 * @return number of bytes consumed by opcode, used to increase pc.
 */
int
op_fneg (instance * it, void * local_variables_init, void * operand_stack)
  {
#   ifdef DEBUG
    printf("none)");
    fflush(NULL);
#   endif
    
    /* TODO */
    
    return 0;
  }

/**
 * Negativate a double.
 * @param it caller method instance
 * @param local_variables_init local variable stack init
 * @param operand_stack operand stack init
 * @return number of bytes consumed by opcode, used to increase pc.
 */
int
op_dneg (instance * it, void * local_variables_init, void * operand_stack)
  {
#   ifdef DEBUG
    printf("none)");
    fflush(NULL);
#   endif
    
    /* TODO */
    
    return 0;
  }

/**
 * Integer shift left.
 * @param it caller method instance
 * @param local_variables_init local variable stack init
 * @param operand_stack operand stack init
 * @return number of bytes consumed by opcode, used to increase pc.
 */
int
op_ishl (instance * it, void * local_variables_init, void * operand_stack)
  {
    s4 *top;
#   ifdef DEBUG
    printf("none)");
    fflush(NULL);
#   endif
    
    top=(s4 *)pop_java(sizeof(s4));
    *(top-1)=*(top-1)<<*top;
    
    return 0;
  }

/**
 * Long shift left.
 * @param it caller method instance
 * @param local_variables_init local variable stack init
 * @param operand_stack operand stack init
 * @return number of bytes consumed by opcode, used to increase pc.
 */
int
op_lshl (instance * it, void * local_variables_init, void * operand_stack)
  {
#   ifdef DEBUG
    printf("none)");
    fflush(NULL);
#   endif
    
    /* TODO */
    
    return 0;
  }

/**
 * Integer shift right.
 * @param it caller method instance
 * @param local_variables_init local variable stack init
 * @param operand_stack operand stack init
 * @return number of bytes consumed by opcode, used to increase pc.
 */
int
op_ishr (instance * it, void * local_variables_init, void * operand_stack)
  {
    s4 *top;
#   ifdef DEBUG
    printf("none)");
    fflush(NULL);
#   endif
    
    top=(s4 *)pop_java(sizeof(s4));
    *(top-1)=*(top-1)>>*top;
    
    return 0;
  }

/**
 * Long shift right.
 * @param it caller method instance
 * @param local_variables_init local variable stack init
 * @param operand_stack operand stack init
 * @return number of bytes consumed by opcode, used to increase pc.
 */
int
op_lshr (instance * it, void * local_variables_init, void * operand_stack)
  {
#   ifdef DEBUG
    printf("none)");
    fflush(NULL);
#   endif
    
    /* TODO */
    
    return 0;
  }

/**
 * Integer logical shift right.
 * @param it caller method instance
 * @param local_variables_init local variable stack init
 * @param operand_stack operand stack init
 * @return number of bytes consumed by opcode, used to increase pc.
 */
int
op_iushr (instance * it, void * local_variables_init, void * operand_stack)
  {
    s4 *top;
#   ifdef DEBUG
    printf("none)");
    fflush(NULL);
#   endif
    
    top=(s4 *)pop_java(sizeof(s4));
    *(top-1)=*(top-1)>>*top;
    
    return 0;
  }

/**
 * Long logical shift right.
 * @param it caller method instance
 * @param local_variables_init local variable stack init
 * @param operand_stack operand stack init
 * @return number of bytes consumed by opcode, used to increase pc.
 */
int
op_lushr (instance * it, void * local_variables_init, void * operand_stack)
  {
#   ifdef DEBUG
    printf("none)");
    fflush(NULL);
#   endif
    
    /* TODO */
    
    return 0;
  }

/**
 * Integer and.
 * @param it caller method instance
 * @param local_variables_init local variable stack init
 * @param operand_stack operand stack init
 * @return number of bytes consumed by opcode, used to increase pc.
 */
int
op_iand (instance * it, void * local_variables_init, void * operand_stack)
  {
    s4 *top;
#   ifdef DEBUG
    printf("none)");
    fflush(NULL);
#   endif
    
    top=(s4 *)pop_java(sizeof(s4));
    *(top-1)=*(top-1)&(*top);
    
    return 0;
  }

/**
 * Long and.
 * @param it caller method instance
 * @param local_variables_init local variable stack init
 * @param operand_stack operand stack init
 * @return number of bytes consumed by opcode, used to increase pc.
 */
int
op_land (instance * it, void * local_variables_init, void * operand_stack)
  {
#   ifdef DEBUG
    printf("none)");
    fflush(NULL);
#   endif
    
    /* TODO */
    
    return 0;
  }

/**
 * Integer or.
 * @param it caller method instance
 * @param local_variables_init local variable stack init
 * @param operand_stack operand stack init
 * @return number of bytes consumed by opcode, used to increase pc.
 */
int
op_ior (instance * it, void * local_variables_init, void * operand_stack)
  {
    s4 *top;
#   ifdef DEBUG
    printf("none)");
    fflush(NULL);
#   endif
    
    top=(s4 *)pop_java(sizeof(s4));
    *(top-1)=*(top-1)|(*top);
    
    return 0;
  }

/**
 * Long double.
 * @param it caller method instance
 * @param local_variables_init local variable stack init
 * @param operand_stack operand stack init
 * @return number of bytes consumed by opcode, used to increase pc.
 */
int
op_lor (instance * it, void * local_variables_init, void * operand_stack)
  {
#   ifdef DEBUG
    printf("none)");
    fflush(NULL);
#   endif
    
    /* TODO */
    
    return 0;
  }

/**
 * Integer xor.
 * @param it caller method instance
 * @param local_variables_init local variable stack init
 * @param operand_stack operand stack init
 * @return number of bytes consumed by opcode, used to increase pc.
 */
int
op_ixor (instance * it, void * local_variables_init, void * operand_stack)
  {
    s4 *top;
#   ifdef DEBUG
    printf("none)");
    fflush(NULL);
#   endif
    
    top=(s4 *)pop_java(sizeof(s4));
    *(top-1)=*(top-1)^(*top);
    
    return 0;
  }

/**
 * Long xor.
 * @param it caller method instance
 * @param local_variables_init local variable stack init
 * @param operand_stack operand stack init
 * @return number of bytes consumed by opcode, used to increase pc.
 */
int
op_lxor (instance * it, void * local_variables_init, void * operand_stack)
  {
#   ifdef DEBUG
    printf("none)");
    fflush(NULL);
#   endif
    
    /* TODO */
    
    return 0;
  }

/**
 * Integer increment.
 * @param it caller method instance
 * @param local_variables_init local variable stack init
 * @param operand_stack operand stack init
 * @return number of bytes consumed by opcode, used to increase pc.
 */
int
op_iinc (instance * it, void * local_variables_init, void * operand_stack)
  {
    u1 index;
    s1 index1;
    u2 index2;
    s2 index3;

    if (ISWIDE)
      {
        memcpy (&index2, getpc() , 2);
        meminv (&index2, 2);
        memcpy (&index3, (u1*)getpc() + 2, 2);
        meminv (&index3, 2);
#       ifdef DEBUG
        printf("%#.4x %#.4x)", index2, index3);
        fflush(NULL);
#       endif
        
        *((s4*)local_variables_init+(int)index2)=*((s4*)local_variables_init+(int)index2)+(int)index3;

        return 4;
      }
    else
      {
        memcpy (&index, getpc() , 1);
        memcpy (&index1, (u1*)getpc() + 1, 1);
#       ifdef DEBUG
        printf("%#.2x %#.2x)", index, index1);
        fflush(NULL);
#       endif

        *((s4*)local_variables_init+(int)index)=*((s4*)local_variables_init+(int)index)+(int)index1;

        return 2;
      }
  }

/**
 * Convert integer to long.
 * @param it caller method instance
 * @param local_variables_init local variable stack init
 * @param operand_stack operand stack init
 * @return number of bytes consumed by opcode, used to increase pc.
 */
int
op_i2l (instance * it, void * local_variables_init, void * operand_stack)
  {
#   ifdef DEBUG
    printf("none)");
    fflush(NULL);
#   endif
    
    /* TODO */
    
    return 0;
  }

/**
 * Convert integer to float
 * @param it caller method instance
 * @param local_variables_init local variable stack init
 * @param operand_stack operand stack init
 * @return number of bytes consumed by opcode, used to increase pc.
 */
int
op_i2f (instance * it, void * local_variables_init, void * operand_stack)
  {
#   ifdef DEBUG
    printf("none)");
    fflush(NULL);
#   endif
    
    /* TODO */
    
    return 0;
  }

/**
 * Convert double to float.
 * @param it caller method instance
 * @param local_variables_init local variable stack init
 * @param operand_stack operand stack init
 * @return number of bytes consumed by opcode, used to increase pc.
 */
int
op_i2d (instance * it, void * local_variables_init, void * operand_stack)
  {
#   ifdef DEBUG
    printf("none)");
    fflush(NULL);
#   endif
    
    /* TODO */
    
    return 0;
  }

/**
 * Convert long to integer.
 * @param it caller method instance
 * @param local_variables_init local variable stack init
 * @param operand_stack operand stack init
 * @return number of bytes consumed by opcode, used to increase pc.
 */
int
op_l2i (instance * it, void * local_variables_init, void * operand_stack)
  {
#   ifdef DEBUG
    printf("none)");
    fflush(NULL);
#   endif
    
    /* TODO */
    
    return 0;
  }

/**
 * convert long to float.
 * @param it caller method instance
 * @param local_variables_init local variable stack init
 * @param operand_stack operand stack init
 * @return number of bytes consumed by opcode, used to increase pc.
 */
int
op_l2f (instance * it, void * local_variables_init, void * operand_stack)
  {
#   ifdef DEBUG
    printf("none)");
    fflush(NULL);
#   endif
    
    /* TODO */
    
    return 0;
  }

/**
 * Convert long to double.
 * @param it caller method instance
 * @param local_variables_init local variable stack init
 * @param operand_stack operand stack init
 * @return number of bytes consumed by opcode, used to increase pc.
 */
int
op_l2d (instance * it, void * local_variables_init, void * operand_stack)
  {
#   ifdef DEBUG
    printf("none)");
    fflush(NULL);
#   endif
    
    /* TODO */
    
    return 0;
  }

/**
 * Convert float to integer.
 * @param it caller method instance
 * @param local_variables_init local variable stack init
 * @param operand_stack operand stack init
 * @return number of bytes consumed by opcode, used to increase pc.
 */
int
op_f2i (instance * it, void * local_variables_init, void * operand_stack)
  {
#   ifdef DEBUG
    printf("none)");
    fflush(NULL);
#   endif
    
    /* TODO */
    
    return 0;
  }

/**
 * Convert float to long.
 * @param it caller method instance
 * @param local_variables_init local variable stack init
 * @param operand_stack operand stack init
 * @return number of bytes consumed by opcode, used to increase pc.
 */
int
op_f2l (instance * it, void * local_variables_init, void * operand_stack)
  {
#   ifdef DEBUG
    printf("none)");
    fflush(NULL);
#   endif
    
    /* TODO */
    
    return 0;
  }

/**
 * Convert float to double.
 * @param it caller method instance
 * @param local_variables_init local variable stack init
 * @param operand_stack operand stack init
 * @return number of bytes consumed by opcode, used to increase pc.
 */
int
op_f2d (instance * it, void * local_variables_init, void * operand_stack)
  {
#   ifdef DEBUG
    printf("none)");
    fflush(NULL);
#   endif
    
    /* TODO */
    
    return 0;
  }

/**
 * Convert double to integer.
 * @param it caller method instance
 * @param local_variables_init local variable stack init
 * @param operand_stack operand stack init
 * @return number of bytes consumed by opcode, used to increase pc.
 */
int
op_d2i (instance * it, void * local_variables_init, void * operand_stack)
  {
#   ifdef DEBUG
    printf("none)");
    fflush(NULL);
#   endif
    
    /* TODO */
    
    return 0;
  }

/**
 * Convert double to long
 * @param it caller method instance
 * @param local_variables_init local variable stack init
 * @param operand_stack operand stack init
 * @return number of bytes consumed by opcode, used to increase pc.
 */
int
op_d2l (instance * it, void * local_variables_init, void * operand_stack)
  {
#   ifdef DEBUG
    printf("none)");
    fflush(NULL);
#   endif
    
    /* TODO */
    
    return 0;
  }

/**
 * Convert double to float.
 * @param it caller method instance
 * @param local_variables_init local variable stack init
 * @param operand_stack operand stack init
 * @return number of bytes consumed by opcode, used to increase pc.
 */
int
op_d2f (instance * it, void * local_variables_init, void * operand_stack)
  {
#   ifdef DEBUG
    printf("none)");
    fflush(NULL);
#   endif
    
    /* TODO */
    
    return 0;
  }

/**
 * Convert integer to byte.
 * @param it caller method instance
 * @param local_variables_init local variable stack init
 * @param operand_stack operand stack init
 * @return number of bytes consumed by opcode, used to increase pc.
 */
int
op_i2b (instance * it, void * local_variables_init, void * operand_stack)
  {
#   ifdef DEBUG
    printf("none)");
    fflush(NULL);
#   endif
    
    /* TODO */
    
    return 0;
  }

/**
 * Convert integer to character.
 * @param it caller method instance
 * @param local_variables_init local variable stack init
 * @param operand_stack operand stack init
 * @return number of bytes consumed by opcode, used to increase pc.
 */
int
op_i2c (instance * it, void * local_variables_init, void * operand_stack)
  {
#   ifdef DEBUG
    printf("none)");
    fflush(NULL);
#   endif
    
    /* TODO */
    
    return 0;
  }

/**
 * Convert integer to short
 * @param it caller method instance
 * @param local_variables_init local variable stack init
 * @param operand_stack operand stack init
 * @return number of bytes consumed by opcode, used to increase pc.
 */
int
op_i2s (instance * it, void * local_variables_init, void * operand_stack)
  {
#   ifdef DEBUG
    printf("none)");
    fflush(NULL);
#   endif
    
    /* TODO */
    
    return 0;
  }

/**
 * Long comparision.
 * @param it caller method instance
 * @param local_variables_init local variable stack init
 * @param operand_stack operand stack init
 * @return number of bytes consumed by opcode, used to increase pc.
 */
int
op_lcmp (instance * it, void * local_variables_init, void * operand_stack)
  {
#   ifdef DEBUG
    printf("none)");
    fflush(NULL);
#   endif
    
    /* TODO */
    
    return 0;
  }

/**
 * Single precision float comparision. -1 to NaN
 * @param it caller method instance
 * @param local_variables_init local variable stack init
 * @param operand_stack operand stack init
 * @return number of bytes consumed by opcode, used to increase pc.
 */
int
op_fcmpl (instance * it, void * local_variables_init, void * operand_stack)
  {
#   ifdef DEBUG
    printf("none)");
    fflush(NULL);
#   endif
    
    /* TODO */
    
    return 0;
  }

/**
 * Single precision float comparision. 1 to NaN
 * @param it caller method instance
 * @param local_variables_init local variable stack init
 * @param operand_stack operand stack init
 * @return number of bytes consumed by opcode, used to increase pc.
 */
int
op_fcmpg (instance * it, void * local_variables_init, void * operand_stack)
  {
#   ifdef DEBUG
    printf("none)");
    fflush(NULL);
#   endif
    
    /* TODO */
    
    return 0;
  }

/**
 * Compare two doubles. -1 to NaN.
 * @param it caller method instance
 * @param local_variables_init local variable stack init
 * @param operand_stack operand stack init
 * @return number of bytes consumed by opcode, used to increase pc.
 */
int
op_dcmpl (instance * it, void * local_variables_init, void * operand_stack)
  {
#   ifdef DEBUG
    printf("none)");
    fflush(NULL);
#   endif
    
    /* TODO */
    
    return 0;
  }

/**
 * Compare two doubles. 1 to NaN
 * @param it caller method instance
 * @param local_variables_init local variable stack init
 * @param operand_stack operand stack init
 * @return number of bytes consumed by opcode, used to increase pc.
 */
int
op_dcmpg (instance * it, void * local_variables_init, void * operand_stack)
  {
#   ifdef DEBUG
    printf("none)");
    fflush(NULL);
#   endif
    
    /* TODO */
    
    return 0;
  }

/**
 * Jump if zero.
 * @param it caller method instance
 * @param local_variables_init local variable stack init
 * @param operand_stack operand stack init
 * @return number of bytes consumed by opcode, used to increase pc.
 */
int
op_ifeq (instance * it, void * local_variables_init, void * operand_stack)
  {
    s4 integer;
    s2 index;
    memcpy (&index, getpc() , 2);
    meminv (&index, 2);
#   ifdef DEBUG
    printf("%#.4x)", index);
    fflush(NULL);
#   endif
    
    integer=*((s4*)pop_java(sizeof(s4)));
    if(0==integer)
      return (int)index-1;
    else
      return 2;
  }

/**
 * Jump if not equal.
 * @param it caller method instance
 * @param local_variables_init local variable stack init
 * @param operand_stack operand stack init
 * @return number of bytes consumed by opcode, used to increase pc.
 */
int
op_ifne (instance * it, void * local_variables_init, void * operand_stack)
  {
    s4 integer;
    s2 index;
    memcpy (&index, getpc() , 2);
    meminv (&index, 2);
#   ifdef DEBUG
    printf("%#.4x)", index);
    fflush(NULL);
#   endif
    
    integer=*((s4*)pop_java(sizeof(s4)));
    if(0!=integer)
      return (int)index-1;
    else
      return 2;
  }

/**
 * Jump if less than.
 * @param it caller method instance
 * @param local_variables_init local variable stack init
 * @param operand_stack operand stack init
 * @return number of bytes consumed by opcode, used to increase pc.
 */
int
op_iflt (instance * it, void * local_variables_init, void * operand_stack)
  {
    s4 integer;
    s2 index;
    memcpy (&index, getpc() , 2);
    meminv (&index, 2);
#   ifdef DEBUG
    printf("%#.4x)", index);
    fflush(NULL);
#   endif
    
    integer=*((s4*)pop_java(sizeof(s4)));
    if(0>integer)
      return (int)index-1;
    else
      return 2;
  }

/**
 * Jump if greater of equal.
 * @param it caller method instance
 * @param local_variables_init local variable stack init
 * @param operand_stack operand stack init
 * @return number of bytes consumed by opcode, used to increase pc.
 */
int
op_ifge (instance * it, void * local_variables_init, void * operand_stack)
  {
    s4 integer;
    s2 index;
    memcpy (&index, getpc() , 2);
    meminv (&index, 2);
#   ifdef DEBUG
    printf("%#.4x)", index);
    fflush(NULL);
#   endif
    
    integer=*((s4*)pop_java(sizeof(s4)));
    if(0<=integer)
      return (int)index-1;
    else
      return 2;
  }

/**
 * Jump if greater than.
 * @param it caller method instance
 * @param local_variables_init local variable stack init
 * @param operand_stack operand stack init
 * @return number of bytes consumed by opcode, used to increase pc.
 */
int
op_ifgt (instance * it, void * local_variables_init, void * operand_stack)
  {
    s4 integer;
    s2 index;
    memcpy (&index, getpc() , 2);
    meminv (&index, 2);
#   ifdef DEBUG
    printf("%#.4x)", index);
    fflush(NULL);
#   endif
    
    integer=*((s4*)pop_java(sizeof(s4)));
    if(0<integer)
      return (int)index-1;
    else
      return 2;
  }

/**
 * Jump if less or equal.
 * @param it caller method instance
 * @param local_variables_init local variable stack init
 * @param operand_stack operand stack init
 * @return number of bytes consumed by opcode, used to increase pc.
 */
int
op_ifle (instance * it, void * local_variables_init, void * operand_stack)
  {
    s4 integer;
    s2 index;
    memcpy (&index, getpc() , 2);
    meminv (&index, 2);
#   ifdef DEBUG
    printf("%#.4x)", index);
    fflush(NULL);
#   endif
    
    integer=*((s4*)pop_java(sizeof(s4)));
    if(0>=integer)
      return (int)index-1;
    else
      return 2;
  }

/**
 * Jump if two integers are equal.
 * @param it caller method instance
 * @param local_variables_init local variable stack init
 * @param operand_stack operand stack init
 * @return number of bytes consumed by opcode, used to increase pc.
 */
int
op_if_icmpeq (instance * it, void * local_variables_init, void * operand_stack)
  {
    s4 integer1, integer2;
    s2 index;
    memcpy (&index, getpc() , 2);
    meminv (&index, 2);
#   ifdef DEBUG
    printf("%#.4x)", index);
    fflush(NULL);
#   endif
    
    integer1=*((s4*)pop_java(sizeof(s4)));
    integer2=*((s4*)pop_java(sizeof(s4)));
    if(integer1==integer2)
      return (int)index-1;
    else
      return 2;
  }

/**
 * Jump if two integers are not equal.
 * @param it caller method instance
 * @param local_variables_init local variable stack init
 * @param operand_stack operand stack init
 * @return number of bytes consumed by opcode, used to increase pc.
 */
int
op_if_icmpne (instance * it, void * local_variables_init, void * operand_stack)
  {
    s4 integer1, integer2;
    s2 index;
    memcpy (&index, getpc() , 2);
    meminv (&index, 2);
#   ifdef DEBUG
    printf("%#.4x)", index);
    fflush(NULL);
#   endif
    
    integer1=*((s4*)pop_java(sizeof(s4)));
    integer2=*((s4*)pop_java(sizeof(s4)));
    if(integer1!=integer2)
      return (int)index-1;
    else
      return 2;
  }

/**
 * Jump if two integers are less than
 * @param it caller method instance
 * @param local_variables_init local variable stack init
 * @param operand_stack operand stack init
 * @return number of bytes consumed by opcode, used to increase pc.
 */
int
op_if_icmplt (instance * it, void * local_variables_init, void * operand_stack)
  {
    s4 integer1, integer2;
    s2 index;
    memcpy (&index, getpc() , 2);
    meminv (&index, 2);
#   ifdef DEBUG
    printf("%#.4x)", index);
    fflush(NULL);
#   endif
    
    integer1=*((s4*)pop_java(sizeof(s4)));
    integer2=*((s4*)pop_java(sizeof(s4)));
    if(integer1>integer2)
      return (int)index-1;
    else
      return 2;
  }

/**
 * Jump if two integers are greater or equal
 * @param it caller method instance
 * @param local_variables_init local variable stack init
 * @param operand_stack operand stack init
 * @return number of bytes consumed by opcode, used to increase pc.
 */
int
op_if_icmpge (instance * it, void * local_variables_init, void * operand_stack)
  {
    s4 integer1, integer2;
    s2 index;
    memcpy (&index, getpc() , 2);
    meminv (&index, 2);
#   ifdef DEBUG
    printf("%#.4x)", index);
    fflush(NULL);
#   endif
    
    integer1=*((s4*)pop_java(sizeof(s4)));
    integer2=*((s4*)pop_java(sizeof(s4)));
    if(integer1<=integer2)
      return (int)index-1;
    else
      return 2;
  }

/**
 * Jump if two integers are greater then
 * @param it caller method instance
 * @param local_variables_init local variable stack init
 * @param operand_stack operand stack init
 * @return number of bytes consumed by opcode, used to increase pc.
 */
int
op_if_icmpgt (instance * it, void * local_variables_init, void * operand_stack)
  {
    s4 integer1, integer2;
    s2 index;
    memcpy (&index, getpc() , 2);
    meminv (&index, 2);
#   ifdef DEBUG
    printf("%#.4x)", index);
    fflush(NULL);
#   endif
    
    integer1=*((s4*)pop_java(sizeof(s4)));
    integer2=*((s4*)pop_java(sizeof(s4)));
    if(integer1<integer2)
      return (int)index-1;
    else
      return 2;
  }

/**
 * Jump if two integers are less or equal
 * @param it caller method instance
 * @param local_variables_init local variable stack init
 * @param operand_stack operand stack init
 * @return number of bytes consumed by opcode, used to increase pc.
 */
int
op_if_icmple (instance * it, void * local_variables_init, void * operand_stack)
  {
    s4 integer1, integer2;
    s2 index;
    memcpy (&index, getpc() , 2);
    meminv (&index, 2);
#   ifdef DEBUG
    printf("%#.4x)", index);
    fflush(NULL);
#   endif
    
    integer1=*((s4*)pop_java(sizeof(s4)));
    integer2=*((s4*)pop_java(sizeof(s4)));
    if(integer1>=integer2)
      return (int)index-1;
    else
      return 2;
  }

/**
 * Jump if two object references are equal
 * @param it caller method instance
 * @param local_variables_init local variable stack init
 * @param operand_stack operand stack init
 * @return number of bytes consumed by opcode, used to increase pc.
 */
int
op_if_acmpeq (instance * it, void * local_variables_init, void * operand_stack)
  {
    u4 *integer1, *integer2;
    s2 index;
    memcpy (&index, getpc() , 2);
    meminv (&index, 2);
#   ifdef DEBUG
    printf("%#.4x)", index);
    fflush(NULL);
#   endif
    
    integer1=(u4*)pop_java(sizeof(u4));
    integer2=(u4*)pop_java(sizeof(u4));
    if(integer1==integer2)
      return (int)index-1;
    else
      return 2;
  }

/**
 * Jump if two object references are not equal.
 * @param it caller method instance
 * @param local_variables_init local variable stack init
 * @param operand_stack operand stack init
 * @return number of bytes consumed by opcode, used to increase pc.
 */
int
op_if_acmpne (instance * it, void * local_variables_init, void * operand_stack)
  {
    u4 *integer1, *integer2;
    s2 index;
    memcpy (&index, getpc() , 2);
    meminv (&index, 2);
#   ifdef DEBUG
    printf("%#.4x)", index);
    fflush(NULL);
#   endif
    
    integer1=(u4*)pop_java(sizeof(u4));
    integer2=(u4*)pop_java(sizeof(u4));
    if(integer1!=integer2)
      return (int)index-1;
    else
      return 2;
  }

/**
 * Goto.
 * @param it caller method instance
 * @param local_variables_init local variable stack init
 * @param operand_stack operand stack init
 * @return number of bytes consumed by opcode, used to increase pc.
 */
int
op_goto (instance * it, void * local_variables_init, void * operand_stack)
  {
    s2 index;
    memcpy (&index, getpc() , 2);
    meminv (&index, 2);
#   ifdef DEBUG
    printf("%#.4x)", index);
    fflush(NULL);
#   endif
    
    return (int)index;
  }

/**
 * Jump to subroutine
 * @param it caller method instance
 * @param local_variables_init local variable stack init
 * @param operand_stack operand stack init
 * @return number of bytes consumed by opcode, used to increase pc.
 */
int
op_jsr (instance * it, void * local_variables_init, void * operand_stack)
  {
    s2 index;
    u4 **top;
    
    memcpy (&index, getpc() , 2);
    meminv (&index, 2);
#   ifdef DEBUG
    printf("%#.4x)", index);
    fflush(NULL);
#   endif
    
    top=(u4 **)push_java(sizeof(u4));
    *top=(u4*)getpc()+2;
    
    return (int)index;
  }

/**
 * Return from subroutine.
 * @param it caller method instance
 * @param local_variables_init local variable stack init
 * @param operand_stack operand stack init
 * @return number of bytes consumed by opcode, used to increase pc.
 */
int
op_ret (instance * it, void * local_variables_init, void * operand_stack)
  {
    u1 index;
    u2 index1;

    if (ISWIDE)
    {
      memcpy (&index1, (u1*)getpc(), 2);
      meminv (&index1, 2);
#     ifdef DEBUG
      printf("%#.4x)", index1);
      fflush(NULL);
#     endif
      return -(int)index1;
    }
    else
    {
      memcpy (&index, getpc() , 1);
#     ifdef DEBUG
      printf("%#.2x)", index);
      fflush(NULL);
#     endif
      return -(int)index;
    }
  }

/**
 * Switch implementation. Close values version.
 * tableswitch opcode
 * 3 bytes of padding
 * s4 offset
 * s4 low
 * s4 high = low + n -1
 * n elements of s4 (labels)
 * 
 * @param it caller method instance
 * @param local_variables_init local variable stack init
 * @param operand_stack operand stack init
 * @return number of bytes consumed by opcode, used to increase pc.
 */
int
op_tableswitch (instance * it, void * local_variables_init, void * operand_stack)
  {
    s4 offset, low, high, integer;
    s4 *labels;
    int i;
    labels=NULL;
    memcpy (&offset, (u1*)getpc()+3, 4);
    meminv (&offset, 4);
    memcpy (&low, (u1*)getpc()+7, 4);
    meminv (&low, 4);
    memcpy (&high, (u1*)getpc()+11, 4);
    meminv (&high, 4);
#   ifdef DEBUG
    printf("%#.4x %#.4x", low, high);
    fflush(NULL);
#   endif
    if (0 < high - low + 1)
      {
        labels = (s4 *)calloc(high - low + 1, sizeof (s4));
        for ( i = 0; i < high - low + 1; i++)
          {
            memcpy (labels + i, (u1*)getpc() + 15 + 4*i, 4);
            meminv (labels + i, 4);
#           ifdef DEBUG
            printf("\n>>                                 - %#4.4x", *(labels + i) );
            fflush(NULL);
#           endif
          }
#       ifdef DEBUG
        printf("\n>>                                 - %#4.4x", offset );
        fflush(NULL);
#       endif
      }
#   ifdef DEBUG
    printf(")");
    fflush(NULL);
#   endif
    
    integer=*((s4*)pop_java(sizeof(s4)));
    
    if((low<=integer)&&(high>=integer)) {
      integer=*(labels+(integer-low));
    } else {
      integer=offset;
    }
    
    if(NULL!=labels)
      free(labels);
    
    return integer-1;
  }

/**
 * Switch implementation. Distant values version.
 * lookupswitch opcode
 * 3 bytes of padding
 * s4 offset
 * s4 n
 * n pair of elements (s4,s4) (key, offset)
 * 
 * @param it caller method instance
 * @param local_variables_init local variable stack init
 * @param operand_stack operand stack init
 * @return number of bytes consumed by opcode, used to increase pc.
 */
int
op_lookupswitch (instance * it, void * local_variables_init, void * operand_stack)
  {
    s4 offset, n, integer, key_temp;
    s4 * key_offset;
    int i;
    short flag;
    
    key_offset=NULL;
    flag=0;
    memcpy (&offset, (u1*)getpc() + 3, 4);
    meminv (&offset, 4);
    memcpy (&n, (u1*)getpc() + 7, 4);
    meminv (&n, 4);
#   ifdef DEBUG
    printf("%#.4x", n);
    fflush(NULL);
#   endif
    if ( 0 < n )
      {
        key_offset = (s4*)calloc(n, sizeof (s4)*2);
        for (i = 0; i < n; i++)
          {
            memcpy (key_offset + 2*i, (u1 *)getpc() + 11 + 8*i, 4);
            meminv (key_offset + 2*i, 4);
            memcpy (key_offset + 2*i + 1, (u1 *)getpc() + 15 + 8*i, 4);
            meminv (key_offset + 2*i + 1, 4);
#           ifdef DEBUG
            printf("\n>>                                 - %#4.4x %#4.4x", *(key_offset + 2*i), *(key_offset + 2*i + 1) );
            fflush(NULL);
#           endif
          }
#       ifdef DEBUG
        printf("\n>>                                 - %#4.4x", offset );
        fflush(NULL);
#       endif
      }
    
    integer=*((s4*)pop_java(sizeof(s4)));
    
    for(i = 0; i < n; i++)
      {
        memcpy(&key_temp, key_offset+2*i, 4);
        meminv(&key_temp, 4);
        if(integer==key_temp)
          {
            memcpy(&key_temp, key_offset+2*i+1, 4);
            meminv(&key_temp, 4);
            integer=key_temp;
            flag=1;
          } 
      }
    
    if(NULL!=key_offset)
      free(key_offset);
    
    if(0==flag)
      integer=offset;
    
    return integer-1;
  }

/**
 * Return an integer.
 * @param it caller method instance
 * @param local_variables_init local variable stack init
 * @param operand_stack operand stack init
 * @return number of bytes consumed by opcode, used to increase pc.
 */
int
op_ireturn (instance * it, void * local_variables_init, void * operand_stack)
  {
    s4 temp;
    s4 *top;
#   ifdef DEBUG
    printf("none)");
    fflush(NULL);
#   endif
    
    top=(s4*)getsp_java();
    temp=*(top-1);
    pop_java((u1*)top-(u1*)local_variables_init-sizeof(s4));
    *((s4 *)local_variables_init)=temp;
    
    return 0;
  }

/**
 * Return a long.
 * @param it caller method instance
 * @param local_variables_init local variable stack init
 * @param operand_stack operand stack init
 * @return number of bytes consumed by opcode, used to increase pc.
 */
int
op_lreturn (instance * it, void * local_variables_init, void * operand_stack)
  {
#   ifdef DEBUG
    printf("none)");
    fflush(NULL);
#   endif
    
    /* TODO */
    
    return 0;
  }

/**
 * Return a float.
 * @param it caller method instance
 * @param local_variables_init local variable stack init
 * @param operand_stack operand stack init
 * @return number of bytes consumed by opcode, used to increase pc.
 */
int
op_freturn (instance * it, void * local_variables_init, void * operand_stack)
  {
#   ifdef DEBUG
    printf("none)");
    fflush(NULL);
#   endif
    
    /* TODO */
    
    return 0;
  }

/**
 * Return a double
 * @param it caller method instance
 * @param local_variables_init local variable stack init
 * @param operand_stack operand stack init
 * @return number of bytes consumed by opcode, used to increase pc.
 */
int
op_dreturn (instance * it, void * local_variables_init, void * operand_stack)
  {
#   ifdef DEBUG
    printf("none)");
    fflush(NULL);
#   endif
    
    /* TODO */
    
    return 0;
  }

/**
 * Return an object reference.
 * @param it caller method instance
 * @param local_variables_init local variable stack init
 * @param operand_stack operand stack init
 * @return number of bytes consumed by opcode, used to increase pc.
 */
int
op_areturn (instance * it, void * local_variables_init, void * operand_stack)
  {
    u4 temp;
    u4 *top;
#   ifdef DEBUG
    printf("none)");
    fflush(NULL);
#   endif
    
    top=(u4*)getsp_java();
    temp=*(top-1);
    pop_java((u1*)top-(u1*)local_variables_init-sizeof(u4));
    *((u4 *)local_variables_init)=temp;
    
    return 0;
  }

/**
 * Return
 * @param it caller method instance
 * @param local_variables_init local variable stack init
 * @param operand_stack operand stack init
 * @return number of bytes consumed by opcode, used to increase pc.
 */
int
op_return (instance * it, void * local_variables_init, void * operand_stack)
  {
#   ifdef DEBUG
    printf("none)");
    fflush(NULL);
#   endif
    
    return INT_MAX;
  }

/**
 * Get value from static field.
 * @param it caller method instance
 * @param local_variables_init local variable stack init
 * @param operand_stack operand stack init
 * @return number of bytes consumed by opcode, used to increase pc.
 */
int
op_getstatic (instance * it, void * local_variables_init, void * operand_stack)
  {
    u2 index;
    memcpy (&index, getpc() , 2);
    meminv (&index, 2);
#   ifdef DEBUG
    printf("%#.4x)", index);
    fflush(NULL);
#   endif
    
    /* TODO */
    
    return 2;
  }

/**
 * Set value of static field.
 * @param it caller method instance
 * @param local_variables_init local variable stack init
 * @param operand_stack operand stack init
 * @return number of bytes consumed by opcode, used to increase pc.
 */
int
op_putstatic (instance * it, void * local_variables_init, void * operand_stack)
  {
    u2 index;
    memcpy (&index, getpc() , 2);
    meminv (&index, 2);
#   ifdef DEBUG
    printf("%#.4x)", index);
    fflush(NULL);
#   endif
    
    /* TODO */
    
    return 2;
  }

/**
 * Get value from object field.
 * @param it caller method instance
 * @param local_variables_init local variable stack init
 * @param operand_stack operand stack init
 * @return number of bytes consumed by opcode, used to increase pc.
 */
int
op_getfield (instance * it, void * local_variables_init, void * operand_stack)
  {
    u2 index;
    memcpy (&index, getpc() , 2);
    meminv (&index, 2);
#   ifdef DEBUG
    printf("%#.4x)", index);
    fflush(NULL);
#   endif
    
    /* TODO */
    
    return 2;
  }

/**
 * Set value of object field.
 * @param it caller method instance
 * @param local_variables_init local variable stack init
 * @param operand_stack operand stack init
 * @return number of bytes consumed by opcode, used to increase pc.
 */
int
op_putfield (instance * it, void * local_variables_init, void * operand_stack)
  {
    u2 index;
    memcpy (&index, getpc() , 2);
    meminv (&index, 2);
#   ifdef DEBUG
    printf("%#.4x)", index);
    fflush(NULL);
#   endif
    
    /* TODO */
    
    return 2;
  }

/**
 * Call an instance method.
 * @param it caller method instance
 * @param local_variables_init local variable stack init
 * @param operand_stack operand stack init
 * @return number of bytes consumed by opcode, used to increase pc.
 */
int
op_invokevirtual (instance * it, void * local_variables_init, void * operand_stack)
  {
    u1 *string, *stack_string;
    u2 index;
    u2 position, size;
    s4 *integer;
    
    memcpy (&index, getpc() , 2);
    meminv (&index, 2);
#   ifdef DEBUG
    printf("%#.4x)", index);
    fflush(NULL);
#   endif
    
    
    memcpy(&position,(it->cf->constant_pool+(int)index-1)->info,2);
    memcpy(&position,(it->cf->constant_pool+(int)position-1)->info+2,2);
    memcpy(&size,(it->cf->constant_pool+(int)position-1)->info,2);
    string=(u1*)calloc(size,sizeof(u1));
    memcpy(string,(it->cf->constant_pool+(int)position-1)->utf8info,size);
    *(string+size)='\0';
    if((!strcmp((char *)string,"println"))||(!strcmp((char *)string,"append")))
      {
        if(0x12 == *((u1 *)getpc() - 3))
          {
            stack_string=*((u1**)pop_java(sizeof(u4)));
            printf("%s",(char *)stack_string);
            fflush(NULL);
            free(stack_string);
          }
        else
          {
            integer=(s4 *)pop_java(sizeof(s4));
            printf("%d",*integer);
            fflush(NULL);
          }
      }
    else
      {
        /* TODO */
      }
    
    return 2;
  }

/**
 * Call method belonging to a specific class.
 * @param it caller method instance
 * @param local_variables_init local variable stack init
 * @param operand_stack operand stack init
 * @return number of bytes consumed by opcode, used to increase pc.
 */
int
op_invokespecial (instance * it, void * local_variables_init, void * operand_stack)
  {
    u1 *string;
    u2 index;
    u2 position, size;

    memcpy (&index, getpc() , 2);
    meminv (&index, 2);
#   ifdef DEBUG
    printf("%#.4x)", index);
    fflush(NULL);
#   endif
    
    memcpy(&position,(it->cf->constant_pool+(int)index-1)->info,2);
    memcpy(&position,(it->cf->constant_pool+(int)position-1)->info+2,2);
    memcpy(&size,(it->cf->constant_pool+(int)position-1)->info,2);
    string=(u1*)calloc(size,sizeof(u1));
    memcpy(string,(it->cf->constant_pool+(int)position-1)->utf8info,size);
    *(string+size)='\0';
    if(!strcmp((char *)string,"<init>"))
      {
        pop_java(sizeof(u4));
      }
    else
      {
        /* TODO */
      }
    
    return 2;
  }

/**
 * Call a method from a static class.
 * @param it caller method instance
 * @param local_variables_init local variable stack init
 * @param operand_stack operand stack init
 * @return number of bytes consumed by opcode, used to increase pc.
 */
int
op_invokestatic (instance * it, void * local_variables_init, void * operand_stack)
  {
    u2 index, position;
    int counter;

    memcpy (&index, getpc() , 2);
    meminv (&index, 2);
#   ifdef DEBUG
    printf("%#.4x)", index);
    fflush(NULL);
#   endif

    memcpy(&position,(it->cf->constant_pool+(int)index-1)->info,2);
    memcpy(&position,(it->cf->constant_pool+(int)position-1)->info+2,2);

    for(counter=2;(position!=(it->cf->methods + counter)->name_index)&&(it->cf->methods_count>counter);counter++);

    if(it->cf->methods_count>counter)
      {
        execute_method(it,counter,operand_stack);
      }
    else
      {
        printf("\nErro ao processar uma chamada a um metodo, metodo invalido.\n");
        exit(1);
      }
      
    return 2;
  }

/**
 * Call an interface method.
 * @param it caller method instance
 * @param local_variables_init local variable stack init
 * @param operand_stack operand stack init
 * @return number of bytes consumed by opcode, used to increase pc.
 */
int
op_invokeinterface (instance * it, void * local_variables_init, void * operand_stack)
  {
    u2 index;
    u1 index1;
    u1 index2;
    memcpy (&index, getpc() , 2);
    meminv (&index, 2);
    memcpy (&index1, (u1*)getpc()+2, 1);
    memcpy (&index2, (u1*)getpc()+3, 1);
#   ifdef DEBUG
    printf("%#.4x %#.2x %#.2x)", index, index1, index2);
    fflush(NULL);
#   endif
    
    /* TODO */
    
    return 4;
  }

/**
 * Unused opcode from some magestic or quite mistical reason.
 * If you know why the hell Gosling decided to do this.. email me. Please.
 * @param it caller method instance
 * @param local_variables_init local variable stack init
 * @param operand_stack operand stack init
 * @return number of bytes consumed by opcode, used to increase pc.
 */
int
op_xxxunusedxxx1 (instance * it, void * local_variables_init, void * operand_stack)
  {
#   ifdef DEBUG
    printf("unused)");
    fflush(NULL);
#   endif
    
    /* TODO */
    
    return 0;
  }

/**
 * Creates an instance of an object.
 * @param it caller method instance
 * @param local_variables_init local variable stack init
 * @param operand_stack operand stack init
 * @return number of bytes consumed by opcode, used to increase pc.
 */
int
op_new (instance * it, void * local_variables_init, void * operand_stack)
  {
    u2 index;
    memcpy (&index, getpc() , 2);
    meminv (&index, 2);
#   ifdef DEBUG
    printf("%#.4x)", index);
    fflush(NULL);
#   endif
    
    /* TODO */
    
    return 2;
  }

/**
 * Create a new array for numbers or boobeans.
 * @param it caller method instance
 * @param local_variables_init local variable stack init
 * @param operand_stack operand stack init
 * @return number of bytes consumed by opcode, used to increase pc.
 */
int
op_newarray (instance * it, void * local_variables_init, void * operand_stack)
  {
    u1 index;
    memcpy (&index, getpc() , 1);
#   ifdef DEBUG
    printf("%#.2x)", index);
    fflush(NULL);
#   endif
    
    /* TODO */
    
    return 1;
  }

/**
 * Create a new array for objects.
 * @param it caller method instance
 * @param local_variables_init local variable stack init
 * @param operand_stack operand stack init
 * @return number of bytes consumed by opcode, used to increase pc.
 */
int
op_anewarray (instance * it, void * local_variables_init, void * operand_stack)
  {
    u2 index;
    memcpy (&index, getpc() , 2);
    meminv (&index, 2);
#   ifdef DEBUG
    printf("%#.4x)", index);
    fflush(NULL);
#   endif
    
    /* TODO */
    
    return 2;
  }

/**
 * Get length of array.
 * @param it caller method instance
 * @param local_variables_init local variable stack init
 * @param operand_stack operand stack init
 * @return number of bytes consumed by opcode, used to increase pc.
 */
int
op_arraylength (instance * it, void * local_variables_init, void * operand_stack)
  {
#   ifdef DEBUG
    printf("none)");
    fflush(NULL);
#   endif
    
    /* TODO */
    
    return 0;
  }

/**
 * Throw an exception.
 * @param it caller method instance
 * @param local_variables_init local variable stack init
 * @param operand_stack operand stack init
 * @return number of bytes consumed by opcode, used to increase pc.
 */
int
op_athrow (instance * it, void * local_variables_init, void * operand_stack)
  {
#   ifdef DEBUG
    printf("none)");
    fflush(NULL);
#   endif
    
    /* TODO */
    
    return 0;
  }

/**
 * Check object or array type.
 * @param it caller method instance
 * @param local_variables_init local variable stack init
 * @param operand_stack operand stack init
 * @return number of bytes consumed by opcode, used to increase pc.
 */
int
op_checkcast (instance * it, void * local_variables_init, void * operand_stack)
  {
    u2 index;
    memcpy (&index, getpc() , 2);
    meminv (&index, 2);
#   ifdef DEBUG
    printf("%#.4x)", index);
    fflush(NULL);
#   endif
    
    /* TODO */
    
    return 2;
  }

/**
 * Test class of object.
 * @param it caller method instance
 * @param local_variables_init local variable stack init
 * @param operand_stack operand stack init
 * @return number of bytes consumed by opcode, used to increase pc.
 */
int
op_instanceof (instance * it, void * local_variables_init, void * operand_stack)
  {
    u2 index;
    memcpy (&index, getpc() , 2);
    meminv (&index, 2);
#   ifdef DEBUG
    printf("%#.4x)", index);
    fflush(NULL);
#   endif
    
    /* TODO */
    
    return 2;
  }

/**
 * Enter syncronized region of code.
 * @param it caller method instance
 * @param local_variables_init local variable stack init
 * @param operand_stack operand stack init
 * @return number of bytes consumed by opcode, used to increase pc.
 */
int
op_monitorenter (instance * it, void * local_variables_init, void * operand_stack)
  {
#   ifdef DEBUG
    printf("none)");
    fflush(NULL);
#   endif
    
    /* TODO */
    
    return 0;
  }

/**
 * Exit syncronized region of code.
 * @param it caller method instance
 * @param local_variables_init local variable stack init
 * @param operand_stack operand stack init
 * @return number of bytes consumed by opcode, used to increase pc.
 */
int
op_monitorexit (instance * it, void * local_variables_init, void * operand_stack)
  {
#   ifdef DEBUG
    printf("none)");
    fflush(NULL);
#   endif
    
    /* TODO */
    
    return 0;
  }

/**
 * Next instruction uses 16bit index.
 * Used to widen the next instruction scope. This way not every instruction need
 * to have a wide version.
 * @param it caller method instance
 * @param local_variables_init local variable stack init
 * @param operand_stack operand stack init
 * @return number of bytes consumed by opcode, used to increase pc.
 */
int
op_wide (instance * it, void * local_variables_init, void * operand_stack)
  {
#   ifdef DEBUG
    printf(")");
    fflush(NULL);
#   endif
    
    /* TODO */
    
    return 0;
  }

/**
 * Multi-Dimensional Array
 * @param it caller method instance
 * @param local_variables_init local variable stack init
 * @param operand_stack operand stack init
 * @return number of bytes consumed by opcode, used to increase pc.
 */
int
op_multianewarray (instance * it, void * local_variables_init, void * operand_stack)
  {
    u2 index;
    u1 index1;
    memcpy (&index, getpc() , 2);
    meminv (&index, 2);
    memcpy (&index1, (u1*)getpc() + 2, 1);
#   ifdef DEBUG
    printf("%#.4x %#.2x)", index, index1);
    fflush(NULL);
#   endif
    
    /* TODO */
    
    return 3;
  }

/**
 * Jump if null.
 * @param it caller method instance
 * @param local_variables_init local variable stack init
 * @param operand_stack operand stack init
 * @return number of bytes consumed by opcode, used to increase pc.
 */
int
op_ifnull (instance * it, void * local_variables_init, void * operand_stack)
  {
    u4 *integer;
    s2 index;
    memcpy (&index, getpc() , 2);
    meminv (&index, 2);
#   ifdef DEBUG
    printf("%#.4x)", index);
    fflush(NULL);
#   endif
    
    integer=(u4*)pop_java(sizeof(u4));
    if(NULL==integer)
      return (int)index-1;
    else
      return 2;
  }

/**
 * Jump if not null.
 * @param it caller method instance
 * @param local_variables_init local variable stack init
 * @param operand_stack operand stack init
 * @return number of bytes consumed by opcode, used to increase pc.
 */
int
op_ifnonnull (instance * it, void * local_variables_init, void * operand_stack)
  {
    u4 *integer;
    s2 index;
    memcpy (&index, getpc() , 2);
    meminv (&index, 2);
#   ifdef DEBUG
    printf("%#.4x)", index);
    fflush(NULL);
#   endif
    
    integer=(u4*)pop_java(sizeof(u4));
    if(NULL!=integer)
      return (int)index-1;
    else
      return 2;
  }

/**
 * Wide goto.
 * @param it caller method instance
 * @param local_variables_init local variable stack init
 * @param operand_stack operand stack init
 * @return number of bytes consumed by opcode, used to increase pc.
 */
int
op_goto_w (instance * it, void * local_variables_init, void * operand_stack)
  {
    s4 index;
    memcpy (&index, getpc() , 4);
    meminv (&index, 4);
#   ifdef DEBUG
    printf("%#.8x)", index);
    fflush(NULL);
#   endif
    
    return (int)index;
  }

/**
 * Jump to subroutine using wide offset.
 * @param it caller method instance
 * @param local_variables_init local variable stack init
 * @param operand_stack operand stack init.
 * @return number of bytes consumed by opcode, used to increase pc.
 */
int
op_jsr_w (instance * it, void * local_variables_init, void * operand_stack)
  {
    s4 index;
    u4 **top;
    
    memcpy (&index, getpc() , 4);
    meminv (&index, 4);
#   ifdef DEBUG
    printf("%#.8x)", index);
    fflush(NULL);
#   endif
    
    top=(u4 **)push_java(sizeof(u4));
    *top=(u4*)getpc()+4;
    
    return (int)index;
  }

/**
 * Breakpoint declaration.
 * @param it caller method instance
 * @param local_variables_init local variable stack init
 * @param operand_stack operand stack init
 * @return number of bytes consumed by opcode, used to increase pc.
 */
int
op_breakpoint (instance * it, void * local_variables_init, void * operand_stack)
  {
#   ifdef DEBUG
    printf("none)");
    fflush(NULL);
#   endif
    
    /* TODO */
    
    return 0;
  }

/**
 * Reserved opcode for java implementation.
 * @param it caller method instance
 * @param local_variables_init local variable stack init
 * @param operand_stack operand stack init
 * @return number of bytes consumed by opcode, used to increase pc.
 */
int
op_impdep1 (instance * it, void * local_variables_init, void * operand_stack)
  {
#   ifdef DEBUG
    printf("none)");
    fflush(NULL);
#   endif
    
    /* TODO */
    
    return 0;
  }

/**
 * Reserved opcode for java implementation.
 * @param it caller method instance
 * @param local_variables_init local variable stack init
 * @param operand_stack operand stack init
 * @return number of bytes consumed by opcode, used to increase pc.
 */
int
op_impdep2 (instance * it, void * local_variables_init, void * operand_stack)
  {
#   ifdef DEBUG
    printf("none)");
    fflush(NULL);
#   endif
    
    /* TODO */
    
    return 0;
  }

/**
 * Print the java stack
 */
void
print_java_stack()
{ 
  u1 * sp; /**>stack_pointer*/
  u1 * bp; /**>base_pointer*/
  int i;
  u1 pjava;
  
  sp = (u1 *)getsp_java();
  bp = (u1 *)getbp_java();

  pjava = 0;
  /*check if empty*/
  if (sp != bp)
    {
      printf("javastack %p %p\n", sp, bp);
      for (i = 1; sp != bp; sp--, i++)
	{
	  printf("%.2x", *((u1 *)sp - 1));
	  if (0 == i % 4)
	      puts("");
	}
      if (1 != i % 4)
	puts("");
    }
}
